Home > Back-end >  New to learn, which bosses to knock a issued by me
New to learn, which bosses to knock a issued by me

Time:10-06

Five students in a class, please define methods recorded their names and achievements, to define a method returns the scores points the serial number of the classmate, according to the user to enter the serial number query results, for the highest output "top", or show results

CodePudding user response:

 
#include

Struct student
{
Char name [10].
Int id;
Float score;
};

Void input_stu (struct student stu [], int n)
{
int i;
for(i=0; i{
The scanf (" % d % s % f ", & amp; Stu [I]. Id, & amp; Stu [I]. Name, & amp; Stu [I] score);
}
}

Int max_score (struct student stu [], int n)
{
Int I, j, temp=0;
for(i=0; i{
If (temp & lt; Stu [I] score)
{
Temp=stu [I] score;
J=I;
}
}
Return stu [j] score;
}

Void find_stu (struct student stu [], int n, int m)
{
Int I, j=0;
for (i=0; i{
If (m==stu [I] id)
{
J=max_score (stu, n);
If (j)==m
{
Printf (" top ");
}
The else
{
Printf (" score: % 2 f ", stu [I] score).
}
}
}
}

Int main ()
{
int m;
Struct student stu [5]={0};

Input_stu (stu, 5);
Printf (" input to query student id: \ n ");
The scanf (" % d ", & amp; M);
Find_stu (stu, 5, m);

return 0;
}

  • Related