Advertisement
vkichukova

Untitled

Nov 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <string>
  4. using namespace std;
  5.  
  6. struct Student
  7. {
  8. string name;
  9. char gender;
  10.  
  11. void print()
  12. {
  13. cout << name << " ";
  14. }
  15. };
  16.  
  17. int main()
  18. {
  19. queue<Student> students;
  20. int n;
  21. cin >> n;
  22. int i = 0;
  23. queue<Student> femaleStudents;
  24. queue<Student> maleStudents;
  25. while(i != n)
  26. {
  27. Student s;
  28. cin >> s.name;
  29. cin >> s.gender;
  30. if(s.gender == 'F')
  31. {
  32. femaleStudents.push(s);
  33. i++;
  34. }
  35. else if(s.gender == 'M')
  36. {
  37. maleStudents.push(s);
  38. i++;
  39. }
  40. else
  41. {
  42. cout << "Error. Enter again\n";
  43. }
  44. }
  45.  
  46. while(!femaleStudents.empty())
  47. {
  48. femaleStudents.front().print();
  49. femaleStudents.pop();
  50. }
  51. while(!maleStudents.empty())
  52. {
  53. maleStudents.front().print();
  54. maleStudents.pop();
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement