你能帮我么?在我运行此代码并且工作正常后,但最后我得到了运行时错误。我的代码运行完美,当我调试时收到消息,例如围绕变量等级的堆栈已损坏。
#include<stdio.h>
#define N 4
int main()
{
int i , j=1,location,x=1;
float grade[N] , total = 0 , average , max;
for(i=0;i<=4;i++)
{
printf("\nPlease enter grade : ");
scanf("%f",&grade[i]);
total = total+grade[i];
}
system("cls");
printf("\nStudent Grade");
for(i=0;i<=N;i++)
{
printf("\n%d %.1f",j,grade[i]);
j++;
}
average = ((total / 500) * 100);
printf("\n--------------------");
printf("\nAverage Grade: %.2f ",average);
for(i=0;i<=4;i++)
{
if(grade[i] > average)
{
location=x+i;
max = grade[i];
printf("\n\nstudent #%d is above the average and value is %.1f",location ,max);
}
}
getch();
}