Home > Back-end >  Run out as a result, please ask me where the program has a problem
Run out as a result, please ask me where the program has a problem

Time:09-21

5 a class, the establishment of a simple student information table, including student id, name, 3 course results, write a program that calculates the average scores and rankings, each student (note: define a structure type, with a structure pointer as a function parameter)

Input format:

Ld % s % % % f f % f

The output format:

% - 9-10 ld % s % 5.1 f % 5.1 f % % 8.1 f % 10.1 f - d \ n

Input the sample:

Zhao 201701 29.8 85.4 65.4
201702 qian 96.5 87.5 65.4
201703 sun 85.4 65.4 84.6
201704 li, 63.4 95.4 86.3
Zhou 201705 65.9 84.6 97.5

The output sample:

Number: Name: score: business: rank:
Zhao 29.8 85.4 65.4 60.2 5 201701
201702 qian 96.5 87.5 65.4 83.1 1
201703 sun 85.4 65.4 84.6 78.5 4
201704 li, 63.4 95.4 86.3 81.7 3
201705 zhou 65.9 84.6 97.5 82.7 2
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --



#include
Struct student
{
Long num.
Char name;
Float score1.
Float score2;
Float score3;
};
Void business (struct student * stu, float aver [])
{
int i;
for(i=0; I<5; I++)
{
Aver [I]=((stu + I) - & gt; Score1 + + I) (stu - & gt; Score2 + + I) (stu - & gt; Score3)/3;
}
}
Void Mr (float aver [], int rank [])
{
Int I, j, a;
for(i=0; I<5; I++)
{
A=5;
for(j=0; J<5; J++)
{
If (aver [I] A=a - 1;
}
Rank [I]=a;
}
}
Int main ()
{
Struct student stu [5].
Int I, rank [5];
Float aver [5].
for(i=0; I<5; I++)
{
The scanf (" % ld % s % f % f % f ", & amp; Stu [I]. Num, stu [I]. Name, & amp; Stu [I]. Score1, & amp; Stu [I]. Score2, & amp; Stu [I] score3);
}
Business (stu, aver);
Mr (aver, rank);
Printf (" Number: Name: score: business: rank: \ n ");
for(i=0; I<5; I++)
{
Printf (" % - 9-10 ld % s % 5.1 f % 5.1 f % % 8.1 f % 10.1 f - d \ n ", stu [I] num, stu [I]. Name, stu [I] score1, stu [I] score2, stu [I] score3, aver [I], rank [I]);
}
return 0;
}

CodePudding user response:

No results? There is no output or the output is wrong? Results posted

CodePudding user response:

Char name;//visual here should be an array of strings

CodePudding user response:

A character array,,

CodePudding user response:

refer to the second floor m0_46108109 response:
char name;//visual here should be an array of strings

Here is how to change

CodePudding user response:

char name[20];

CodePudding user response:

If the rules how long name maximum input, the char name [len]//len for length
  • Related