#include <iostream>
#include <string>
using namespace std;
const int n = 5;
struct home {
string famely;
int nomer;
int ocenka[5];
};
home Copy(home st) {
home newSt;
newSt.famely = st.famely;
for (int i = 0; i < 5; i++) {
newSt.ocenka[i] = st.ocenka[i];
}
newSt.nomer = st.nomer;
return newSt;
}
int main() {
setlocale(LC_ALL, "rus");
home* st = new home[n];
for (int i = 0; i != n; i++) {
cout << "Введите ФИО" << endl;
cin >> st[i].famely;
cout << "Введите номер группы" << endl;
cin >> st[i].nomer;
cout << "Успеваемость" << endl;
int j = 0;
do {
cout << "Оценка" << endl;
cin >> st[i].ocenka[j];
j++;
} while (j != 5);
cout << endl;
}
cout << endl;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (st[i].famely.compare(st[j].famely) > 0) {
home buf = Copy(st[i]);
st[i] = st[j];
st[j] = buf;
}
}
}
for (int i = 0; i != n; i++) {
cout << "Фамилия " << st[i].famely << endl;
cout << "Номер группы" << st[i].nomer << endl;
for (int j = 0; j != 5; j++) {
cout << st[i].ocenka[j] << " ";
}
cout << endl;
}
cout << endl;
cout << "Двоечники: " << endl;
for (int i = 0; i != n; i++) {
for (int j = 0; j < 5; j++)
if (st[i].ocenka[j] == 2)
{
cout << "Фамилия " << st[i].famely << endl;
cout << "Номер группы " << st[i].nomer << endl;
cout << endl;
}
}
delete[]st;
system("pause");
return 0;
}