Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Student{
- char surname[30];
- int marks[5];
- int sum;
- };
- int main()
- {
- int m;
- printf("Enter the count of studens: ");
- scanf("%d",&m);
- struct Student students[m];
- for (int i=0;i<m;i++){
- printf("Enter the surname of student: ");
- scanf("%s", students[i].surname);
- printf("Enter the mark for math: ");
- scanf("%d", &students[i].marks[0]);
- printf("Enter the mark for inform: ");
- scanf("%d", &students[i].marks[1]);
- printf("Enter the mark for programming: ");
- scanf("%d",&students[i].marks[2]);
- printf("Enter the mark for phisic: ");
- scanf("%d",&students[i].marks[3]);
- printf("ENter the mark for history: ");
- scanf("%d", &students[i].marks[4]);
- printf("---------------------------------------\n");
- students[i].sum = students[i].marks[0]+students[i].marks[1]+students[i].marks[2]+students[i].marks[3]+students[i].marks[4];
- }
- printf("Enter the number for subject: ");
- int subjectnumber;
- scanf("%d",&subjectnumber);
- for (int i=0;i<m;i++){
- if (students[i].marks[subjectnumber-1] > 60){
- printf("%s\n",students[i].surname);
- printf("---------------------------------------\n");
- }
- }
- for (int i=0;i<m;i++){
- for (int j=0;j<m;j++){
- if (students[i].sum>students[j].sum){
- struct Student c = students[i];
- students[i] = students[j];
- students[j] = c;
- }
- }
- }
- for (int i=0;i<3;i++){
- printf("%s\n",students[i].surname);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement