Advertisement
evgenko

Leo_H_lab10

Dec 13th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct Student{
  4.     char surname[30];
  5.     int marks[5];
  6.     int sum;
  7. };
  8. int main()
  9. {
  10.     int m;
  11.     printf("Enter the count of studens: ");
  12.     scanf("%d",&m);
  13.     struct Student students[m];
  14.     for (int i=0;i<m;i++){
  15.         printf("Enter the surname of student: ");
  16.         scanf("%s", students[i].surname);
  17.         printf("Enter the mark for math: ");
  18.         scanf("%d", &students[i].marks[0]);
  19.         printf("Enter the mark for inform: ");
  20.         scanf("%d", &students[i].marks[1]);
  21.         printf("Enter the mark for programming: ");
  22.         scanf("%d",&students[i].marks[2]);
  23.         printf("Enter the mark for phisic: ");
  24.         scanf("%d",&students[i].marks[3]);
  25.         printf("ENter the mark for history: ");
  26.         scanf("%d", &students[i].marks[4]);
  27.         printf("---------------------------------------\n");
  28.         students[i].sum = students[i].marks[0]+students[i].marks[1]+students[i].marks[2]+students[i].marks[3]+students[i].marks[4];
  29.     }
  30.     printf("Enter the number for subject: ");
  31.     int subjectnumber;
  32.     scanf("%d",&subjectnumber);
  33.     for (int i=0;i<m;i++){
  34.         if (students[i].marks[subjectnumber-1] > 60){
  35.             printf("%s\n",students[i].surname);
  36.             printf("---------------------------------------\n");
  37.         }
  38.     }
  39.     for (int i=0;i<m;i++){
  40.         for (int j=0;j<m;j++){
  41.             if (students[i].sum>students[j].sum){
  42.                 struct Student c = students[i];
  43.                 students[i] = students[j];
  44.                 students[j] = c;
  45.             }
  46.         }
  47.     }
  48.  
  49.     for (int i=0;i<3;i++){
  50.         printf("%s\n",students[i].surname);
  51.     }
  52.  
  53.  
  54.     return 0;
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement