fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. class sv{
  6. public:
  7. string ma, ten, lop, mail;
  8. void nhap()
  9. {
  10. cin>>ma;
  11. getchar();
  12. getline(cin, ten);
  13. cin>>lop>>mail;
  14. }
  15.  
  16. void in()
  17. {
  18. cout<<ma<<" "<<ten<<" "<<lop<<" "<<mail<<endl;
  19. }
  20. };
  21.  
  22. bool cmp(sv a, sv b)
  23. {
  24. if(a.lop==b.lop) return a.ma<b.ma;
  25. return a.lop<b.lop;
  26. }
  27.  
  28. int main()
  29. {
  30. int n; cin>>n;
  31. vector<sv> ds(n);
  32.  
  33. for(int i=0;i<n;++i)
  34. {
  35. ds[i].nhap();
  36. }
  37.  
  38. sort(ds.begin(),ds.end(),cmp);
  39.  
  40. for(int i=0;i<n;++i)
  41. {
  42. ds[i].in();
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5288KB
stdin
4
B16DCCN011
Nguyen Trong Duc Anh
D16CNPM1
sv1@stu.ptit.edu.vn
B15DCCN215
To Ngoc Hieu
D15CNPM3
sv2@stu.ptit.edu.vn
B15DCKT150
Nguyen Ngoc Son
D15CQKT02-B
sv3@stu.ptit.edu.vn
B15DCKT199
Nguyen Trong Tung
D15CQKT03-B
sv4@stu.ptit.edu.vn
stdout
B15DCCN215 To Ngoc Hieu D15CNPM3 sv2@stu.ptit.edu.vn
B15DCKT150 Nguyen Ngoc Son D15CQKT02-B sv3@stu.ptit.edu.vn
B15DCKT199 Nguyen Trong Tung D15CQKT03-B sv4@stu.ptit.edu.vn
B16DCCN011 Nguyen Trong Duc Anh D16CNPM1 sv1@stu.ptit.edu.vn