Advertisement
Josif_tepe

Untitled

Mar 20th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct student {
  5.     string ime;
  6.     string prezime;
  7.     int indeks;
  8.     double prosek;
  9. };
  10.  
  11. int main() {
  12.     int n;
  13.     cin >> n;
  14.    
  15.     student s[n];
  16.     for(int i = 0; i < n; i++) {
  17.         cin >> s[i].ime >> s[i].prezime >> s[i].indeks >> s[i].prosek;
  18.     }
  19.     for(int i = 0; i < n; i++) {
  20.         for(int j = i + 1; j < n; j++) {
  21.             if(s[i].indeks > s[j].indeks) {
  22.                 student pomosna = s[i];
  23.                 s[i] = s[j];
  24.                 s[j] = pomosna;
  25.             }
  26.         }
  27.     }
  28.     for(int i = 0; i < n; i++) {
  29.         cout << s[i].ime << " " << s[i].prezime << " " << s[i].indeks << " " << s[i].prosek << endl;
  30.     }
  31.    
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement