josiftepe

Untitled

Nov 15th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. struct student{
  4. string ime;
  5. string prezime;
  6. int brojnaindex;
  7. double prosek;
  8. };
  9. int main()
  10. {
  11.  
  12. int N;
  13. cin>>N;
  14. student niza[N];
  15.  
  16. for(int i=0; i<N; i+=1){
  17.     cin>>niza[i].ime;
  18.     cin>>niza[i].prezime;
  19.     cin>>niza[i].brojnaindex;
  20.     cin>>niza[i].prosek;
  21. }
  22.  
  23. for(int p=0; p<N; p+=1){
  24.     for(int y=p+1; y<N; y+=1){
  25.         if(niza[p].brojnaindex>niza[y].brojnaindex){
  26.             swap(niza[p],niza[y]);
  27.         }
  28.     }
  29. }
  30.     cout << endl;
  31. for(int u=0; u<N; u+=1){
  32.     cout<<niza[u].ime << " " ;
  33.     cout<<niza[u].prezime << " ";
  34.     cout<<niza[u].brojnaindex << " " ;
  35.     cout<<niza[u].prosek << " ";
  36.     cout << endl;
  37. }
  38.  
  39.  
  40.  
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment