#include
#define N 40
int main()
{
float score[N],maxScore;
long num[N],maxNum;
int n,i;
printf("请输入班级人数:\n");
scanf("%d", &n);
printf("请输入学生学号及分数:\n");
for(i = 0; i < n; i++)
{
scanf("%ld%f", &num[i], &score[i]);
}
Findmax(n, num, score, &maxScore, &maxNum);
printf("maxNum = %ld, maxScore = %f", maxNum, maxScore);
}
void Findmax(int n, long num[], float score[], float *maxScore, long *maxNum)
{
*maxScore = score[0];
*maxNum = num[0];
for(int i = 1; i < n; i++)
{
if(score[i] > *maxScore)
{
*maxScore = score[i];
*maxNum = num[i];
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)