Home > Back-end >  The c language
The c language

Time:09-28

There are 50 students in a class, each student elective courses, 30 requirements:
1. The design of algorithm, the average of the class and grade each course, the highest and lowest points; 2. The total score of each course each student, sorted by total score from high to low, the flow chart of traditional algorithm to solve the above problems and the corresponding C language program,

CodePudding user response:

The Description
Input 10 students, each student's data, including student id, name, 3 course results, define the type of structure type said students, 10 students input data,
Calculation of each student's grade point average, according to the average score from high to low output information for all students, grades phase at the same time, according to the student id from small to large, output

{
Input format
10 students information, each a student

The input sample
1 aaa 50 to 60 70
2 BBB 50 fifty
3 CCC 60, 70, 80
4 DDD 40 40 40
5 the eee, 70, 80, 90
6 FFF 30 30 30
GGG 7, 80, 90, 100
8 HHH 20 20 20
9, 100, 100, 100 iii
10 JJJ 10 10 10

The output sample
9, 100, 100, 100 iii
GGG 7, 80, 90, 100
5 the eee, 70, 80, 90
3 CCC 60, 70, 80
1 aaa 50 to 60 70
2 BBB 50 fifty
4 DDD 40 40 40
6 FFF 30 30 30
8 HHH 20 20 20
10 JJJ 10 10 10
}
 # include & lt; Stdio. H> 

Struct data
{
Int num.
char name[100];
Float score [3].
Float avg, sum;
};

Int main ()
{
int i,j;
Struct data stu [10], TMP;
for(i=0; I<10; I++)
{
Printf (" please enter the student's student id: ");
The scanf (" % d ", & amp; Stu [I] num);

Printf (" please enter the student's name: ");
The scanf (" % s ", stu [I] name);

Stu [I] sum=0;
For (j=0; J & lt; 3; J++)
{
Printf (" please input the student's first grade: % d door ", j + 1);
The scanf (" % f ", & amp; Stu [I] score [j]);
Stu [I] sum +=stu [I] score [j];
}

Stu [I]. Avg=stu [I] sum/3;
Printf (" the student's grade point average is: %, 2 f ", stu [I]. Avg);
Printf (" \ n \ n ");
}

for(i=0; I<9. I++)
for(j=0; J<9 - I; J++)
{
If (stu [j]. Journal of avg & lt; Stu [j + 1] avg)
{
TMP=stu [j];
Stu [j]=stu [j + 1);
Stu [j + 1)=TMP;
}
Else if (stu [j]. Journal of avg==stu [j + 1] avg)
{
If (stu [j]. Journal of num & gt; Stu [j + 1] num)
{
TMP=stu [j];
Stu [j]=stu [j + 1);
Stu [j + 1)=TMP;
}
}
}

for(i=0; I<10; I++)
{
Printf (" % d % s % 0 lf %. 0 lf %. 0 lf \ n ", stu [I] num, stu [I]. Name, stu [I] score [0], stu [I] score [1], stu [I] score [2]).
}
return 0;
}


Involves the use of the structure, the subject, for reference only
  • Related