|
我写了一段程序如下:
void gradeavage()
{
int i = 0;
int score1;
int score2;
int score3;
int score;
int avage1,avage2,avage3,avage;
char gradenum[10];
struct student *info;
info = start;
printf("\n 请输入要查询的年级:");
scanf("%s",&gradenum);
while (info)
{
if (!strcmp(gradenum,info -> grade_num))
{
i = i + 1;
score1 = info -> chinese;
score2 = info -> math;
score3 = info -> english;
score1++;
score2++;
score3++;
score = score1 + score2 + score3;
info = info -> next;
}
else info = info -> next;
}
info = findgrade(gradenum);
if (!info) printf("\n 没有这个年级!!!\n");
else
{
avage1 = score1 / i;
avage2 = score2 / i;
avage3 = score3 / i;
avage = score / i;
printf("\n 语文的平均分:%s",avage1);
printf("\n 数学的平均分:%s",avage2);
printf("\n 英语的平均分:%s",avage3);
printf("\n 总分的平均分:%s",avage);
}
}
但是运行时候说内存不可读!!!!!
郁闷!!!!!!!!!!!!!!! :-( :-( |
|