我的“半成品”程序(学生管理系统) 明天就要检查了但还没有完成
#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];
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 *p);
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;
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,m=0,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; }
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; ;
printf("pingjunfen%f\n",p1,p2,p3);/*平均成绩p1为英语,p2为数学,p3为语文*/
}
void gaofen(struct student *p) /*打印出平均分最高的学生信息 */
{
{
}
}
void syxinxi(struct student *p) /* 显示所有学生信息*/
{
int i,j;
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 stu1[]) /* 添加一个学生的记录*/
{
}
void shanchu(struct student stu1[]) /* 删除一个学生的记录 */
{
}