Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iterator>
- #include <fstream>
- #include <string>
- #include <queue>
- #include <array>
- using namespace std;
- class Student
- {
- static const int SES_NUM = 5;
- string name, surname, secondname, gender;
- int age;
- array<int, SES_NUM> 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<Student> 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment