为啥我的代码会runtime error呀
求助orz!!!
#include <stdio.h>
#include <malloc.h>
#include <math.h>
using namespace std;
struct Student
{
int Chinese, Math, English;
char name[9];
};
int sum[1001] = {0};
struct Student * p;
int main (void)
{
int people;
scanf("%d", &people);
p = (struct Student *)malloc(people * 21);
for (int i=0; i<people; i++)
{
scanf("%s%d%d%d", p[i].name, &p[i].Chinese, &p[i].Math, &p[i].English);
sum[i] = p[i].Chinese + p[i].Math + p[i].English;
}
for (int i=0; i<people-1; i++)
{
for (int j=i+1; j<people; j++)
{
if (abs(p[i].Chinese - p[j].Chinese) <= 5
&& abs(p[i].Math - p[j].Math) <= 5
&& abs(p[i].English - p[j].English) <= 5
&& abs(sum[i] - sum[j]) <= 10)
printf("%s %s\n",p[i].name, p[j].name);
}
}
return 0;
}