1、学生成绩管理系统c语言代码学生成绩管理系统c语言代码(总20页) getchar(); scanf(%c,&ch); if(ch=y|ch=Y) printf(n继续!); getch(); flag=1;/*标志程序不结束*/ else flag=0; while(flag=1); save_message(); printf(按任意键继续.); getch();/*insert()模块*/ /*被输入和插入模块所调用*/int insert(struct STH*h) struct STH *p,*p0; p=(struct STH*)malloc(N); printf(n请输入学号:);
2、 scanf(%ld,&p-num); printf(n请输入姓名:); scanf(%s,p-name); printf(n请输入性别:); getchar(); /*取走上一个留下来得n*/ scanf(%s,p-sex); printf(n请输入生日(年月日,用回车隔开):n); scanf(%d%d%d,&p-birth.year,&p-birth.month,&p-birth.day); printf(n请输入系别:); scanf(%s,p-xi); printf(n请输入班级:); scanf(%s,p-ban); printf(n请输入家庭住址:); scanf(%s,p-ad
3、d); p-next=NULL; if(*h=NULL) *h=p; return 1; p0=*h; if(p0-nump-num) p-next=p0; *h=p; return 1; while(p0-next!=NULL&p0-next-numnum) p0=p0-next; if(p0-next=NULL) p0-next=p; return 1; else if(p0-next-num=p-num) free(p); /*有相同数据输入失败*/ return 0; else p-next=p0-next; p0-next=p; return 1; /*读文件模块*/ /*读文件模块
4、中创建了一个新的链表,其返回值为新链表的头指针*/struct STH *readfile() FILE *fp; struct STH *p,*p0; char ch; int i; if(fp=fopen(STH.txt,r)=NULL) printf(n不能读取文件!n); return NULL; /*注意要该*/ head=p=p0=(struct STH *)malloc(N); fscanf(fp,%d,&n); fscanf(fp,%c,&ch); /*为了使学号和信息个数分开加入一个/*/ fscanf(fp,%ld%s%s%d%d%d%s%s%s, &p-num,p-nam
5、e,p-sex,&p-birth.year,&p-birth.month,&p-birth.day,p-xi,p-ban,p-add); p-next=NULL; i=1; /*如果只有一个数时跳出*/ if(n!=1) do p=(struct STH *)malloc(N); fscanf(fp,%ld%s%s%d%d%d%s%s%s, &p-num,p-name,p-sex,&p-birth.year,&p-birth.month,&p-birth.day,p-xi,p-ban,p-add); p0-next=p; p0=p; i+; while(inext=NULL; fclose(f
6、p); return head;/*插入模块*/insert_message() struct STH *p; int flag=1; char ch; head=readfile(); do if(insert(&head)!=0) n+; save_message(); printf(); /*计数*/ else printf(n添加失败!n有相同的的学号!); save_message(); getch(); printf(n是否继续(y/n); getchar(); ch=getchar(); if(ch=y|ch=Y) printf(n继续!); flag=1;/*标志程序不结束*/
7、 else flag=0; while(flag=1); printf(n按任意键继续.); getch();/*修改模块*/renew_message() struct STH *p; int i,flag=1; long num; p=head=readfile(); if(head=NULL) printf(读文件有误!); getch(); else printf(n请按输入要修改的学生的学号:); scanf(%ld,&num); for(i=0;inum=num) p-num=num; printf(n已找到要%ld号学生的信息!n,num); printf(原姓名为%s 要修改为
8、:n,p-name); scanf(%s,p-name); printf(原性别为%s 要修改为:n,p-sex); scanf(%s,p-sex); printf(原生日为%d/%d/%d 要修改为:n,p-birth.year,p-birth.month,p-birth.day); scanf(%d%d%d,&p-birth.year,&p-birth.month,&p-birth.day); printf(原系别为%s 要修改为:n,p-xi); scanf(%s,p-xi); printf(原班级为%s 要修改为:n,p-ban); scanf(%s,p-ban); printf(原家
9、庭住址为%s 要修改为:n,p-add); scanf(%s,p-add); printf(你所更改后的信息为:n); printf(PRINTF); printf(GESHI, p-num,p-name,p-sex,p-birth.year,p-birth.month,p-birth.day,p-xi,p-ban,p-add); printf(n按任意键退出!n); getch(); flag=1; break; else p=p-next; if(flag!=1) printf(无此人信息!n); else save_message(); getch(); /*删除模块*/delete_m
10、essage() int flag; long num; char ch; struct STH*p,*p0; p0=p=head=readfile(); if(head=NULL) printf(文件读取出错!); getch(); else printf(请输入要删除学生的学号:n); scanf(%ld,&num); if(p0-num=num) head=p0-next; free(p0); flag=1; n-; /*学生数减一*/ p=p0-next; while(p!=NULL) if(p-num=num) p0-next=p-next; free(p); flag=1; n-;
11、 else p0=p; p=p-next; if(p-next=NULL) flag=0; if(flag=1) printf(n永久删除%ld号学生的信息(y/n),num); getchar(); ch=getchar(); if(ch=y|ch=Y) save_message(); else printf(n撤消删除!); getch(); else printf(n删除失败!); getch(); /*查询模块*/inquire_message() int i,flag=0; long num; struct STH *p; p=head=readfile(); if(head=NUL
12、L) printf(文件读取出错!); getch(); else printf(请输入要查询学生的学号:n); scanf(%ld,&num); for(i=0;inum=num) printf(n信息已找到:n); getch(); clrscr(); printf(*FOUND*n); printf(-nn); printf(PRINTF); printf(GESHI, p-num,p-name,p-sex,p-birth.year,p-birth.month,p-birth.day,p-xi,p-ban,p-add); printf(n-n); printf(*END*n); flag
13、=1;break; else p=p-next; if(flag=0) printf(n无此人信息!); else printf(n显示完毕!按任意键返回主菜单.); getch(); /*显示模块*/output_message() int i=0; struct STH*p; p=head=readfile(); if(head=NULL) printf(文件读取出错!); getch(); else clrscr(); printf(n*STUDENT*n); printf(-n); printf(PRINTF); while(inum,p-name,p-sex,p-birth.year
14、,p-birth.month,p-birth.day,p-xi,p-ban,p-add); p=p-next; i+; printf(-n); printf(*END*n); printf(n显示完毕!n共%d条信息.n按任意键返回主菜单.,n); getch(); /*存档模块*/save_message() FILE *fp; int i; struct STH*p; p=head; if(fp=fopen(STH.txt,w)=NULL) printf(读文件错误!); exit(0); fprintf(fp,%d,n); fprintf(fp,%c,/); /*注意要该*/ for(i
15、=0;inum,p-name,p-sex,p-birth.year,p-birth.month,p-birth.day,p-xi,p-ban,p-add); p=p-next; fclose(fp); printf(n信息已经保存在STH.txt文件中!); getch(); /*主函数*/void main(void) int choice; char ch; FILE *fp; struct date d; getdate(&d); if(fp=fopen(STH.txt,r)=NULL) fp=fopen(STH.txt,w); fprintf(fp,%d,0); fclose(fp);
16、 else fscanf(fp,%d,&n); fclose(fp); clrscr(); printf(制作人:通工0501 李艺凡); printf(nnn); printf( * n); printf( 欢迎进入学生户籍系统 nn); printf( 1 创建记录n); printf( 2 添加记录n); printf( 3 查找记录n); printf( 4 删除记录n); printf( 5 修改记录n); printf( 6 显示全部信息n); printf( 0 退出程序n); printf( * n); printf( %d年%d月%d日,d.da_year,d.da_mon,d.da_day); printf( n 请选择(0-6):); scanf(%d,&choice); if(n=0) /*记录为空时不让其进行其他操作*/