Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <string>
- using namespace std;
- struct Student
- {
- string name;
- char gender;
- void print()
- {
- cout << name << " ";
- }
- };
- int main()
- {
- queue<Student> students;
- int n;
- cin >> n;
- int i = 0;
- queue<Student> femaleStudents;
- queue<Student> maleStudents;
- while(i != n)
- {
- Student s;
- cin >> s.name;
- cin >> s.gender;
- if(s.gender == 'F')
- {
- femaleStudents.push(s);
- i++;
- }
- else if(s.gender == 'M')
- {
- maleStudents.push(s);
- i++;
- }
- else
- {
- cout << "Error. Enter again\n";
- }
- }
- while(!femaleStudents.empty())
- {
- femaleStudents.front().print();
- femaleStudents.pop();
- }
- while(!maleStudents.empty())
- {
- maleStudents.front().print();
- maleStudents.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement