Advertisement
evgenko

lab_10_marina

Dec 11th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.49 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct Profile{
  4.     char surnane[30];
  5.     int school;
  6.     int class;
  7.     int place;
  8.  
  9. };
  10.  
  11. int main(){
  12.     printf("Enter the count of profiles: ");
  13.     int n;
  14.     scanf("%d",&n);
  15.     struct Profile profiles[n];
  16.     int maxschoolnumber = 0;
  17.     for (int i=0;i<n;i++){
  18.         printf("Enter the name of pupil: ");
  19.         scanf("%s",profiles[i].surnane);
  20.         printf("Enter the number of school: ");
  21.         scanf("%d",&profiles[i].school);
  22.         printf("Enter the class number: ");
  23.         scanf("%d",&profiles[i].class);
  24.         printf("Enter the number of place: ");
  25.         scanf("%d",&profiles[i].place);
  26.         printf("----------------------------------");
  27.         if (profiles[i].school > maxschoolnumber)
  28.             maxschoolnumber = profiles[i].school;
  29.     }
  30.     int schools[maxschoolnumber+1];
  31.     for (int i=0;i<maxschoolnumber+1;i++){
  32.         schools[i]=0;
  33.     }
  34.     for (int i=0;i<n;i++){
  35.         if (profiles[i].place <=3){
  36.             schools[profiles[i].school]++;
  37.         }
  38.     }
  39.     int max_prize = 0;
  40.     int i_max_prize = 0;
  41.     printf("Schools with prizes: ");
  42.     for (int i=0;i<maxschoolnumber+1;i++){
  43.         if (schools[i])
  44.             printf("%d ",i);
  45.         if (max_prize<schools[i]){
  46.             max_prize = schools[i];
  47.             i_max_prize = i;
  48.         }
  49.     }
  50.     printf("\nSchool with max count of prizes: ");
  51.     printf("%d", i_max_prize);
  52.     return 0;
  53. }
  54.  
  55.  
  56. /*
  57.  
  58.  
  59. lol kek cheburek
  60. cheburek kek lol
  61.  
  62.  
  63.  
  64.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement