//要求录入学号及对应的分数,找到最高分数,输出最高分数及对应的学号#include <stdio.h>#define N 80int main(){ int n; int score[N];//分数 int number[N];//学号 int maxNum,maxScore; printf("Input:how many students in the class:\n"); scanf("%d",&n); printf("Input:the student number and the score"); int i; for(i=0;i<n;i++){ scanf("%d %d",&number[i],&score[i]); }//输入学号及对应的分数 findMax(&maxScore,&maxNum,n,number[],score[]); printf("maxNum=%d,maxScore=%d",*maxNum,*maxNum); return 0;}//定义函数:寻找最大分数 void findMax(int* maxScore,int* maxNum,int n,int number[],int score[]){ *maxScore=score[0]; *maxNum=number[0]; int i; for(i=1;i<n;i=++){ if(score[i]>*maxScore){ *maxScore=score[i]; *maxNum=number[i]; } } }
1 回答
- 1 回答
- 0 关注
- 1498 浏览
添加回答
举报
0/150
提交
取消