[problem description] there are 10 students, each student's data, including student id, name, 3 course results, 10 students from the keyboard input data, output 3 course requirements an average time of 10 students, and students of the highest data (including student id, name, 3 course results, the average score), please use the structure design of the data of the student,
[form] input
Student id name season 1 2 grades 3
Student id name season 1 2 grades 3
.
Student id name season 1 2 grades 3
Student number 1 ~ 10, name is less than 10 Chinese characters, can not leave a space between each word, grade 1 digit after decimal point,
[] output form
Average 1
Student id name season 1 2 grades 3 score
Average 2
Student id name season 1 2 grades 3 score
3 grade point average 3
Student id name season 1 2 grades 3 score
Each course consists of two lines of information, the first line is the course information, including course number and the average score of the course, the second line is the course of the top students of information, the average is divided into the three classes of students scores, divide the output performance of peace 1 digit after decimal point, the output format: printf (" % d % 5.1 f \ n % 5 d % s % 5.1 f % 5.1 f % 5.1 f % 5.1 f \ n ",
[sample input]
1 of my however, parr, 90, 85, 89
2 Deng Yanli, 85, 90, 87
3 Feng Wenhao, 78, 89, 96
Hey ma beautiful 4, 83, 83, 90
5 Gao Shuai, 69, 82, 70
6 GuXiangHong, 92, 83, 70
7 Guo Tinghao, 80, 79, 90
Huang Yuyao 8, 70, 80, 93
9 Jin Changpu 90 60 60
10 receive health care, 98, 69, 85
[sample output]
0
83.5
10 receive health 98.0 69.0 85.0 84.0
1
80.0
2 Deng Yanli 85.0 90.0 87.0 87.3
2, 83.0
3 Feng Wenhao 78.0 89.0 96.0 87.7
CodePudding user response:
Don't write nothing, do nothing, let others help you write good, debugging right, others not so carefree, if you really want to pay to others ~Worthwhile things to think about good, not so much good ~
Now like to hand in the homework, why go early?
CodePudding user response:
#include# define N 10
Struct Student
{
int num;
Char name [10].
Float score [3].
Float aver.
};
Int main ()
{
int i;
Struct Student stu [N].
Struct Student * p=stu.
Void business (struct Student stu [N]);
for(i=0; i
The scanf (" % d % s % f % f % f ", & amp; Stu [I]. Num, stu [I]. Name, & amp; Stu [I] score [0], & amp; Stu [I] score [1], & amp; Stu [I] score [2]);
Stu [I] aver=(stu [I] score stu [0] + [I] score [1] + stu [I] score [2])/3;
}
Business (p);
return 0;
}
Void business (struct Student stu [N])
{
Int I, j, k, Max [3].
Float sum,
Aver [3].
for(i=0; i<3; I++)
{
Sum=0;
for(j=0; j
Score the sum +=stu [j]. [I];
Max [I]=j;
For (k=1; K
If (stu [j] score [I]
Max [I]=k;
}
}
}
Aver [I]=sum/3;
}
for(i=0; i<3; I++)
{
Printf (" % d % 5.1 f \ n % 5 d % s % 5.1 f % 5.1 f % 5.1 f % 5.1 f \ n ", I, aver [I], Max [I], stu [Max [I]]. Name,
Stu [Max [I]] score [0], stu [Max [I]] score [1], stu [Max [I]].
Score [2], stu [Max [I]] aver);
}
}
CodePudding user response:
That there is wrong, can you help to have a look at, the result is not quite rightCodePudding user response:
# include & lt; Stdio. H>
# define N 3
Struct Student
{
int num;
Char name [10].
Float score [3].
Float aver.
};
Int main ()
{
int i;
Struct Student stu [N].
Struct Student * p=stu.
Void business (struct Student stu [N]);
for(i=0; i{
The scanf (" % d % s % f % f % f ", & amp; Stu [I]. Num, stu [I]. Name, & amp; Stu [I] score [0], & amp; Stu [I] score [1], & amp; Stu [I] score [2]);
//stu [I] aver=(stu [I] score stu [0] + [I] score [1] + stu [I] score [2])/3;
Stu [I] aver=(stu [I] score stu [0] + [I] score [1] + stu [I] score [2])/3.0;
}
Business (p);
return 0;
}
Void business (struct Student stu [N])
{
Int I, j, k, Max [3].
Float sum,
Aver [3].
for(i=0; i<3; I++) {
Sum=0;
Max [I]=0;
for(j=0; jScore the sum +=stu [j]. [I];
If (stu [j] score [I] & gt; Stu [Max [I]] score [I])
Max [I]=j;
}
Aver [I]=sum/3.0;
}
/*
for(i=0; i<3; I++)
{
Sum=0;
for(j=0; j{
Score the sum +=stu [j]. [I];
For (k=1; K{
If (stu [j] score [I]{
Max [I]=k;
}
}
}
Aver [I]=sum/3;
}
*/
for(i=0; i<3; I++)
{
Printf (" % d % 5.1 f \ n % 5 d % s % 5.1 f % 5.1 f % 5.1 f % 5.1 f \ n ", I, aver [I], Max [I], stu [Max [I]]. Name,
Stu [Max [I]] score [0], stu [Max [I]] score [1], stu [Max [I]].
Score [2], stu [Max [I]] aver);
}
}
For your reference ~
To compare the code to find your own problem
CodePudding user response: