#include #include #include #include #include #include #include using namespace std; class Student { static const int SES_NUM = 5; string name, surname, secondname, gender; int age; array ses; public: friend ifstream& operator >> (ifstream& in, Student& st); friend ofstream& operator<< (ofstream& out, const Student& st); bool pass_exams() const { return *min_element(ses.begin(), ses.end()) > 2; } }; ifstream& operator >> (ifstream& in, Student& st) { in >> st.surname >> st.name >> st.secondname >> st.gender >> st.age; for (int i = 0; i < st.SES_NUM; ++i) in >> st.ses[i]; return in; } ofstream& operator << (ofstream& out, const Student& st) { out << st.surname << " " << st.name << " " << st.secondname << " " << st.gender << " " << st.age << " "; for (int i = 0; i < st.SES_NUM; ++i) out << st.ses[i] << " "; return out; } int main() { queue pass, not_pass; Student tmp; string in_name = "input.txt", out_name = "output.txt"; ifstream in(in_name); int st_num; in >> st_num; for (int i = 0; i < st_num; ++i) { in >> tmp; if (tmp.pass_exams()) pass.push(tmp); else pass.push(tmp); } in.close(); ofstream out(out_name); while (!pass.empty()) { out << pass.front() << endl; pass.pop(); } while (!not_pass.empty()) { out << not_pass.front() << endl; not_pass.pop(); } out.close(); cout << "Done" << endl; }