Написать задачу в C++ в которой записи о депутатах(фамилия, возраст, кол-во набранных голосов). Выбрать информацию о депутате, набравшем наименьшее количество голосов
Ответы
Ответ:
Объяснение:
#include <iostream>
#include <string>
using namespace std;
int main()
{
setlocale (LC_ALL, "Rus");
int i, max;
const int SIZE = 2;
struct Politics
{
string name, surname;
int age, votes;
};
Politics ListOfCandidats[SIZE];
for (int i = 0; i < SIZE; i++)
{
cout << "Введите имя политика: "; cin >> ListOfCandidats[i].name;
cout << "Введите фамилию политика: "; cin >> ListOfCandidats[i].surname;
cout << "Введите сколько политику лет: "; cin >> ListOfCandidats[i].age;
cout << "Введите сколько голосов у политика: "; cin >> ListOfCandidats[i].votes;
cout << endl;
}
cout << "---------------------------------" << endl;
cout << "Список политиков"<<endl;
cout << "---------------------------------" << endl;
for (int i = 0; i < SIZE; i++)
{
cout<<"Имя и фамилия: ";
cout<<ListOfCandidats[i].name << " " << ListOfCandidats[i].surname << endl;
cout<<"Количество лет: ";
cout<<ListOfCandidats[i].age << endl;
cout<<"Количество голосов: ";
cout<<ListOfCandidats[i].votes << endl;
cout << "---------------------------------" << endl;
}
max = ListOfCandidats[0].votes;
for (int i = 0; i < SIZE; i++)
{
if (ListOfCandidats[i].votes <= max)
{
cout<<"Политик набравший меньше всего голосов: "<< ListOfCandidats[i].name << " "<< ListOfCandidats[i].surname<< endl;
cout<<"Количество лет: "<< ListOfCandidats[i].age<< endl;
cout<<"Количество голосов: "<<ListOfCandidats[i].votes<< endl;
}
}
}