Home > Back-end >  C language problems, seek help, clearly the result of the output and the output sample, the result j
C language problems, seek help, clearly the result of the output and the output sample, the result j

Time:09-20

. Write a program to realize the data input from the keyboard 3 students (each student's data, including student id, name, 2 course grades), output each student class 2 grade point average, and high score student data (including student id, name, class 2, average score),
Input format:
Input data from three students, each student a line of data format is as follows: & lt; Student id & gt; Note: student id/name does not contain whitespace, student id for 8-bit characters, the name for a maximum of 20 characters,
The output format:
Out of the first in line 1 of the output of 3 students grade point average, the average output format for accounted for 10, 1 decimal place,
In line 2 output data, the highest students format is as follows: No=& lt; Student id & gt; , Name=& lt; Name & gt; The Score1=& lt; The first course grades & gt; , Score2=& lt; The second course grade & gt; , business=& lt; Average & gt;
Note: keep the output of the course grades and gpa 1 decimal places and rounded,
Input the sample:
20180001 zhangsan 70.0 80.0
20180002 lisi 95.0 89.0
20180003 wangwu 65.0 84.0

The output sample:
75.0 92.0 74.5
No=20180002, Name=lisi, Score1=95.0, Score2=89.0, business=92.0

The referee sample testing program:
#include
Int main () {

Please fill in the answer here */*/

Printf (" Name=\ nNo=% s, % s, Score1.=% 1 f, Score2.=% 1 f, business.=% 1 f ", s [Max] no, s [Max]. Name, s [r]. Max Score1, s [r]. Max Score2, s [Max] business);
Return 0;
}
This is the code I wrote
Struct student
{
Char no [9];
char name[20];
Float score1.
Float score2;
Float business;
} s [3].
Int m, n, Max;
Float sum [3].
For (n=0; n<3; N++)
The scanf (" % s % s % f % f ", s [n]. No, s [n]. The name, & amp; S [n]. Score1, & amp; S [n]. Score2);
For (n=0; n<3; N++)
S [n]. Business=(s [n]. Score1 + s [n]. Score2)/2.0;
Printf (" % 10.1 f % 10.1 f % 10.1 f ", s [0]. Business, s [1]. Business, s [2]. Business);
For (m=0; M<3; M++)
If (sum [n] & gt; The sum [m])
Max=n;

CodePudding user response:

It's probably an it site bug

CodePudding user response:

Try to get rid of the inside of the printf Spaces

CodePudding user response:

20180001 zhangsan 70.0 80.0
20180002 lisi 95.0 89.0
20180003 wangwu 65.0 84.0
Numerical read error?
  • Related