I need to display 3 students with the highest exam points(the sum of them) Exams are : math,physics,english,attestat. There is only entering and displaying data in code. It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Mystruct
{
string surname;
int birthday;
double math;
double physics;
double english;
double attestat;
};
int main()
{
vector<Mystruct> Myvector;
int n;
cout << " Enter amount of students";
cin >> n;
for (int i = 0; i <n; ++i)
{
Myvector.push_back(Mystruct());
cout << "Surname - " << endl;
cin >> Myvector[i].surname;
cout << "Birthday date - " << endl;
cin >> Myvector[i].birthday;
cout << "Math -" << endl;
cin >> Myvector[i].math;
cout << "Physics -" << endl;
cin >> Myvector[i].physics;
cout << "English -" << endl;
cin >> Myvector[i].english;
cout << "Attestat -" << endl;
cin >> Myvector[i].attestat;
}
cout <<"Surname:" << "\t" << "Birthday" << "\t" << "Math:" << "\t" << "Physics:" << "\t" << "English:" << "\t" << "Attestat:" << endl;
for (int i = 0; i < n; ++i)
{
cout << Myvector[i].surname << "\t" << Myvector[i].birthday << "\t\t" << Myvector[i].math << "\t" <<Myvector[i].physics << "\t\t" <<Myvector[i].english << "\t\t" << Myvector[i].attestat << endl;
}
/* double max = Myvector[0].math + Myvector[0].physics + Myvector[0].english + Myvector[0].attestat;
for (int i = 1; i < n; ++i)
{
if (Myvector[0].math + Myvector[0].physics + Myvector[0].english + Myvector[0].attestat > max)
}
*/
return 0;
}
Aucun commentaire:
Enregistrer un commentaire