怎么改,输入时可以覆盖原数据
/*jinjin 0905209*/#include <stdio.h>
#include <stdlib.h>
int main()
{
int grades[20];
int index;
int value;
int i=0;
double sum=0;
double average;
i=0;
do
{
printf("Enter student number: ");
scanf("%d", &index);
if (index >= 0 && index < 20)
{
printf("Enter grade for student number %d:", index);
scanf("%d", &value);
grades[index] = value;
}
else if (index==-1)
break;
else
{
printf("You entered an invalid student number\n");
}
i++;
sum+=grades[index];
}
while(i<20);
average=sum/i;
printf("the average grade is %4.2f",average);
return 0;
}
相同的学号,不同的成绩;怎么改可以覆盖啊?