Advertisement
Guest User

student

a guest
Mar 23rd, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.34 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. struct student {
  6.     char ime[15];
  7.     char prezime[15];
  8.     int index;
  9.     int poeni;
  10.    
  11. } studenti[100];
  12.  
  13. void golemiPocetniBukvi(int n){
  14.     int i;
  15.     for(i = 0; i < n; i++){
  16.         studenti[i].ime[0] = toupper(studenti[i].ime[0]);
  17.         studenti[i].prezime[0] = toupper(studenti[i].prezime[0]);
  18.     }
  19. }
  20.  
  21. void sort(int n){
  22.     int i,j;
  23.     struct student pom;
  24.     for (i = 0 ; i < n - 1; i++){
  25.         for (j = 0 ; j < n - i - 1; j++)
  26.         {
  27.             if (studenti[j].poeni < studenti[j+1].poeni)
  28.             {
  29.                 pom = studenti[j];
  30.                 studenti[j] = studenti[j+1];
  31.                 studenti[j+1] = pom;
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37. int main()
  38. {
  39.     int i, n, j;
  40.     scanf("%d", &n);
  41.    
  42.     for(i = 0; i < n; i++){
  43.         scanf("%s", &studenti[i].ime);
  44.         scanf("%s", &studenti[i].prezime);
  45.         scanf("%d", &studenti[i].index);
  46.         int poeni = 0;
  47.         studenti[i].poeni = 0;
  48.         for(j = 0; j < 4; j++){
  49.             scanf("%d", &poeni);
  50.             studenti[i].poeni += poeni;
  51.         }
  52.     }
  53.    
  54.     golemiPocetniBukvi(n);
  55.     sort(n);
  56.    
  57.     for(i = 0; i < n; i++){
  58.         printf("%s %s %d %d\n", studenti[i].prezime, studenti[i].ime, studenti[i].index, studenti[i].poeni);
  59.     }
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement