我这个程序不能运行
#include <assert.h>#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct student
{int num;
char name[8];
int yingyu;
int shuxue;
int yuwen;
};
void main()
{int i;
struct student stu[5];
struct student *p;
void input(struct student stu1[]);
void zongchengji(struct student *p );
void pingjun(struct student *p);
void gaofen(struct student *p);
void syxinxi(struct student *p);
void tianjia(struct student stu1[]);
void shanchu(struct student *p);
while(1)
{printf("**********************************\n");
printf("******欢迎登陆学生查询系统********\n");
printf("******[1]输入学生信息*************\n");
printf("******[2]打印四门课的总成绩*******\n");
printf("******[3]打印出平均成绩***********\n");
printf("******[4]打印最高分学生信息*******\n");
printf("******[5]显示所有学生信息*********\n");
printf("******[6]添加一个学生记录*********\n");
printf("******[7]删除一些学生记录*********\n");
printf("******[0]退出*********************\n");
scanf("%d",&i);
switch(i)
{case 1:input(stu);break;
case 2:zongchengji(stu);break;
case 3:pingjun(stu);break;
case 4:gaofen(stu);break;
case 5:syxinxi(stu);break;
case 6:tianjia(stu);break;
case 7:shanchu(stu);break;
case 0:exit(0);
default:printf("error\n");
}
}
}
void input(struct student stu1[])
{int i;
for(i=0;i<5;i++)
{printf("\ninput scores of student %d:\n",i+1);
printf("num:");
scanf("%d",&(stu1[i].num));
printf("name:");
scanf("%s",&(stu1[i].name));
printf("yingyu:");
scanf("%d",&(stu1[i].yingyu));
printf("shuxue:");
scanf("%d",&(stu1[i].shuxue));
printf("yuwen:");
scanf("%d",&(stu1[i].yuwen));}
}
void zongchengji(struct student *p) /*各科总成绩*/
{
int i,m1=0,m2=0,m3=0;
for(i=0;i<5;i++)
{ m1=m1+(p+i)->yingyu;
m2=m2+(p+i)->shuxue;
m3=m3+(p+i)->yuwen; }
clrscr();
printf("zongchengji:yingyu=%dshuxue=%dyuwen=%d\n",m1,m2,m3);
}
void pingjun(struct student *p) /*各科平均成绩*/
{int i,m1=0,m2=0,m3=0;
float p1,p2,p3;
for(i=0;i<5;i++)
{ m1=m1+(p+i)->yingyu;
m2=m2+(p+i)->shuxue;
m3=m3+(p+i)->yuwen; }
p1=m1/5;p2=m2/5;p3=m3/5;
clrscr();
printf("pingjunfen%f\n",p1,p2,p3);/*平均成绩p1为英语,p2为数学,p3为语文*/
}
void gaofen(struct student *p) /*打印出总评分平均分最高的学生信息 */
{ int i,j,sum1=0,sum2=0,sum3=0,sum,ping;
for(i=0;i<5;i++)
sum1+=(p+i)->yingyu;
sum2+=(p+i)->shuxue;
sum3+=(p+i)->yuwen;
sum=sum1+sum2+sum3;
ping[i]=sum/3;
max=ping[0];
if(max<ping[i])
{max=ping[i] ;j=i;
pringtf("max=%d%d",max,j);}
else
{j=0; printf("max=%d",max) ;}
}
}
void syxinxi(struct student *p) /* 显示所有学生信息*/
{
int i,j;
clrscr();
printf("\n") ;
printf("************学生信息*********\n");
printf("-----------------------------\n");
printf("|%s|%s|%s|%s|%s|\n","num","name","yingyu","shuxue","yuwen");
printf("-----------------------------\n");
for(i=0;i<5;i++)
{ printf("|%d|%s|%d|%d|%d|\n",(p+i)->num,(p+i)->name,(p+i)->yingyu,(p+i)->shuxue,(p+i)->yuwen);}
printf("------------------------\n");
}
void tianjia(struct student *p) /* 添加一个学生的记录*/
{int y=1,n;
do{printf("-----------------");
printf("请输入学生学号:");
scanf("%d",&p->num);
printf("请输入学生姓名");
scanf("%s",&p->name);
printf("请输入学生的英语:");
scanf("%d",&p->yingyu);
printf("请输入学生的数学:");
scanf("%d",&p->shuxue);
printf("请输入学生的语文:");
scanf("%d",&p->yuwen);
n++;
p++;
printf("\n1.继续输入.\n0.输入完毕.\n");
printf("请选择:");
scanf("%d",&y);
}
while(y==1);
printf("提示:输入完毕!你一共输入%d个\n",n);
}
void shanchu(struct student stu1[]) /* 删除一个学生的记录 */
{ int num;
int i,j,e,n;
if(n!=0)
{
printf("学号\t姓名\t英语\t数学\t语文\t\n");
printf("-----------------------------------------------------\n");
for(i=0;i<n;i++)
printf("%d%s%d%d%d\n",stu1[i].num,stu1[i].name,stu1[i].yingyu,stu1[i].shuxue,stu1[i].yuwen);
printf("请输入您要删除的学生的学号:");
scanf("%d", &num);
printf("\n");
for(i=0;i<n;i++)
if(num==stu1[i].num)
j=i;
if(j!=(n-1))
{
for(e=i-1;e<n;e++,j++)
{
stu1[j].num=stu1[j+1].num;
strcpy(stu1[j].name,stu1[j+1].name);
stu1[j].yuwen=stu1[j+1].yuwen;
stu1[j].shuxue=stu1[j+1].shuxue;
stu1[j].yingyu=stu1[j+1].yingyu;
n--;
}
}else n--;
printf("提示:删除完毕!");
}
}
删除不了学生个人信息和求平均分最高的学生信息