Advertisement
Guest User

progkont

a guest
Oct 21st, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct slog {
  5. string ime, prezime;
  6. double uspeh;
  7. }
  8. ucenik[1005];
  9.  
  10. bool cmp(slog a, slog b){
  11. return a.uspeh < b.uspeh or a.uspeh == b.uspeh and a.ime < b.ime or a.uspeh == b.uspeh and a.ime == b.ime and a.prezime < b.prezime;
  12. }
  13.  
  14. int brojUcenika;
  15. int main() {
  16. cin >> brojUcenika;
  17. for (int i = 1; i <= brojUcenika; i++) {
  18.     cin >> ucenik[i].ime >> ucenik[i].prezime >> ucenik[i].uspeh;
  19. }
  20. sort(ucenik+1, ucenik+brojUcenika+1, cmp);
  21.  
  22. for (int i = 1; i <= brojUcenika; i++) {
  23.     cout << ucenik[i].ime << " " << ucenik[i].prezime << " " << ucenik[i].uspeh << endl;
  24. }
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement