#include <stdlib.h>
#define N 40
int ReadScore(int a[],long num[]);
int FindMax(int a[],long num[],int n,int *pmaxs,int *pmaxn);
int main()
{
int n,pmaxs,pmaxn;
int a[N];
long num[N];
n=ReadScore(a,num);
printf("%d\n",n);
FindMax(a,num,n,&pmaxs,&pmaxn);
printf("%d %d\n",pmaxs,pmaxn);
return 0;
}
int ReadScore(int a[],long num[])
{
int i=-1;
do{
i++;
printf("输入成绩和学号:");
scanf("%d%ld",&a[i],&num[i]);
}while(a[i]>=0&&num[i]>=0);
return i;
}
int FindMax(int a[],long num[],int n,int *pmaxs,int *pmaxn)
{
int i;
*pmaxs=a[0];
*pmaxn=num[0];
for(i=0;i<n;i++)
{
if(a[i]>*pmaxs)
{
*pmaxs=a[i];
*pmaxn=num[i];
}
}
}
知识点:函数调用与数组和指针的运用