#include <string>
#include <iostream>
#include <vector>
const int max_number_of_students=2;
const int grades_count = 3;
struct RecordBook // да, так будет зачетка
{
std::string last_name;
int no;
int grades[grades_count]; // раньше это называлось "ocenka"
};
int main()
{
/*
Фамилия студента
Номер зачетки
Массив из 4 оценок
* Сортировка структур по фамилии или среднему баллу
* Удаление всех зачеток троечников
*/
std::vector<RecordBook> box;
RecordBook t;
for(int i = 0; i < max_number_of_students; i++)
{
std::cout << "Enter Last Name:" << std::endl;
getline(std::cin, t.last_name);
std::cout << "Enter Nomer:" << std::endl;
std::cin >> t.no;
std::cout << "Enter grades (count:"<< grades_count <<")" << std::endl;
for (int j = 0; j < grades_count; j++)
std::cin >> t.grades[j];
std::cin.ignore(50, '\n');
box.push_back(t);
}
//- Cортировка по фамилии
// Здесь хорошо бы применить стандартный алгоритм сортировки, но боюсь это будет перебор.
for(size_t i=box.size()-1; i>0 ; i--)
for(size_t j=0; j<i ; j++)
if(box[ j ].last_name > box[ j+1 ].last_name)
{
std::swap(box[j], box[j+1]);
// три строки ниже - олд-скул вариант.
//RecordBook t = box[j];
//box[j] = box[j+1];
//box[j+1] = t;
}
for(size_t i=0; i<box.size(); i++)
{
bool is_find = false;
for (int j = 0; j < grades_count; j++) {
if (box[i].grades[j] == 3) {
is_find = true;
break;
}
}
if (is_find)
continue;
std::cout << box[i].last_name << std::endl << box[i].no << std::endl;
for(int j=0; j<grades_count; j++)
std::cout << box[i].grades[j] << " ";
std::cout << std::endl;
}
return 0;
}