[Plain] # include <stdio. h>
# Include <stdlib. h>
Void print (struct students * p); // print the definition of the function print
Void max_score (struct students * p); // function max Definition
Struct students // definition of the struct students
{
Char number [15];
Float score;
};
Int main (int argc, char * argv [])
{
Struct students num [5] = {"121", 88.8 },{ "122", 77.7 },{ "123", 48.4 },{ "124", 99.1 }, {"125", 78.3 }};
Print (num );
Max_score (num );
System ("PAUSE ");
Return 0;
}
// Definition of function
// ** Print
Void print (struct students * p)
{
Int I;
I = 0;
While (I <5)
{
Printf ("% d student scored is % 0.2f \ n", I + 1, p [I]);
I + = 2;
}
}
// ** Max_score
Void max_score (struct students * p)
{
Struct students t; // used to save the maximum number of students
Int I;
Int j;
For (I = 0; I <4; I ++) // sort by score
{
For (j = 0; j <5; j ++)
{
If (p [I]. score> p [j]. score)
{
T = p [I]; // The student ID and score are also exchanged.
P [I] = p [j];
P [j] = t;
}
}
}
Printf ("The highest score is % f, and he number is % s \ n", p [0]. score, p [0]. number );
}
# Include <stdio. h>
# Include <stdlib. h>
Void print (struct students * p); // print the definition of the function print
Void max_score (struct students * p); // function max Definition
Struct students // definition of the struct students
{
Char number [15];
Float score;
};
Int main (int argc, char * argv [])
{
Struct students num [5] = {"121", 88.8 },{ "122", 77.7 },{ "123", 48.4 },{ "124", 99.1 }, {"125", 78.3 }};
Print (num );
Max_score (num );
System ("PAUSE ");
Return 0;
}
// Definition of function
// ** Print
Void print (struct students * p)
{
Int I;
I = 0;
While (I <5)
{
Printf ("% d student scored is % 0.2f \ n", I + 1, p [I]);
I + = 2;
}
}
// ** Max_score
Void max_score (struct students * p)
{
Struct students t; // used to save the maximum number of students
Int I;
Int j;
For (I = 0; I <4; I ++) // sort by score
{
For (j = 0; j <5; j ++)
{
If (p [I]. score> p [j]. score)
{
T = p [I]; // The student ID and score are also exchanged.
P [I] = p [j];
P [j] = t;
}
}
}
Printf ("The highest score is % f, and he number is % s \ n", p [0]. score, p [0]. number );
}