fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. vector<string> Slytherin, Hufflepuff, Gryffindor, Ravenclaw;
  8. int n;
  9. (cin >> n).get();
  10. for (int i = 0; i < n; i++)
  11. {
  12. string s, s1;
  13. getline (cin, s);
  14. (cin >> s1).get();
  15. // cout << s << endl << s1 << endl;
  16. if (s1 == "Slytherin") Slytherin.push_back(s);
  17. else if (s1 =="Hufflepuff") Hufflepuff.push_back(s);
  18. else if (s1 =="Gryffindor") Gryffindor.push_back(s);
  19. else if (s1 =="Ravenclaw") Ravenclaw.push_back(s);
  20. }
  21. cout << endl << endl;
  22. if (Slytherin.size()>0)
  23. {
  24. cout << "Slytherin:" << endl;
  25. for (int i = 0; i < Slytherin.size(); i++)
  26. cout << Slytherin[i] << endl;
  27. }
  28. if (Hufflepuff.size()>0)
  29. {
  30. cout<< endl << "Hufflepuff:" << endl;
  31. for (int i = 0; i < Hufflepuff.size(); i++)
  32. cout << Hufflepuff[i] << endl;
  33. }
  34. if (Gryffindor.size()>0)
  35. {
  36. cout<< endl << "Gryffindor:" << endl;
  37. for (int i = 0; i < Gryffindor.size(); i++)
  38. cout << Gryffindor[i] << endl;
  39. }
  40. if (Ravenclaw.size()>0)
  41. {
  42. cout<< endl << "Ravenclaw:" << endl;
  43. for (int i = 0; i < Ravenclaw.size(); i++)
  44. cout << Ravenclaw[i] << endl;
  45. }
  46.  
  47. cin.get();
  48. return 0;
  49. }
Success #stdin #stdout 0s 3480KB
stdin
7
 Ivan Ivanov
 Gryffindor
 Mac Go Nagolo
 Hufflepuff
 Zlobeus Zlei
 Slytherin
 Um Bridge
 Slytherin
 Tatiana Henrihovna Grotter
 Ravenclaw
 Garry Potnyj
 Gryffindor
 Herr Mionag-Ranger
 Gryffindor
stdout

Slytherin:
 Zlobeus Zlei
 Um Bridge

Hufflepuff:
 Mac Go Nagolo

Gryffindor:
 Ivan Ivanov
 Garry Potnyj
 Herr Mionag-Ranger

Ravenclaw:
 Tatiana Henrihovna Grotter