为什么在 C++ 中能运行 却达不到预期的效果
#include<stdio.h>#define N 30
void FindMax(int score[],long num[],int n,int *pMaxScore,long*pMaxNum);
int main()
{
int score[N],maxScore;
int n,i;
long num[N],maxNum;
printf("How many students?");
scanf("%d",&n);
printf("Input students's ID and scre:\n");
for(i=0;i<n;i++)
{
scanf("% 1d%d",&num[i],&score[i]);
}
FindMax(score,num,n,&maxScore,&maxNum);//输入学号和 分数 ,然后输出最大值和相关的学号
printf("maxScore=%d,maxNum=%1d\n",maxScore,maxNum);
return 0;
}
void FindMax(int score[],long num[],int n,int*pMaxScore,long *pMaxNum)
{
int i;
*pMaxScore=score[0];
*pMaxNum=num[0];
for(i=1;i<n;i++)
{
if(score[i]>*pMaxScore)
{
*pMaxScore=score[i];
*pMaxNum=num[i];
}
}
}