C语言实现学生档案管理系统
本文实例为大家分享了C语言实现学生档案管理系统的具体代码,供大家参考,具体内容如下
文章图片
文章图片
文章图片
文章图片
文章图片
文章图片
文章图片
文章图片
文章图片
/*课程设计项目名称:学生档案管理系统作者:施瑞文 时间:2018.3.3 */#include#include#include#include#include #define N sizeof(struct Student)#define M sizeof(struct Password)#define MAX 1000 struct Student{char number[10]; //学号char name[10]; //姓名char sex[2]; //性别struct Birthday//出生日期 {int year; //年int month; //月int day; //日 }birtnday; struct Score//成绩{float c_language; //c语言float math; //高数float Russian; //俄语float Russian_hearing; //俄语听力float professional; //专业导论float politics; //政治 }score; char remark[100]; //备注 int num; struct Student *next; }; typedef struct Student Stu; typedef Stu *Stup; typedef struct Password{char password[18]; struct Password *next; }pass; typedef pass *passw; typedef struct TOTAL//总分 {char number[10]; char name[10]; char sex[2]; float c_language; //c语言float math; //高数float Russian; //俄语float Russian_hearing; //俄语听力float professional; //专业导论float politics; //政治float sum; }Total; Total total[MAX]; //好多自定义函数 void color(short x); //设置颜色void HideCursor(); //隐藏光标void toxy(int x, int y); //将光标移动到X,Y坐标处void menu(); //主菜单 void over(); //退出软件void signin(); //登陆 passw ff(); //将文件中的内容读入链表,返回值为表头地址 void save_password(passw p); //保存密码 void amend_password(); //修改密码 void input_information(); //信息录入 void amend_information(); //修改信息 void delete_information(); //删除信息 void delete_number(); //按学号查询删除void delete_name(); //按姓名查询删除 void save_information(Stup p); //保存信息 void print_information(); //信息显示 Stup ss(); //将文件中的内容读入链表,返回值为表头地址void find_information(); ///查找信息 void find_number_information(); //按学号查询 void find_name_information(); //按姓名查询 void statistics_information(); //信息统计 void average_score(); //平均分void total_score_ranked(); //总分排名void fail_numbers(); //各科不及格人数 void assignment(); //将信息赋值到一个结构体中 void grade_table(); //各科成绩分布 void analyze_c(); //c语言 void analyze_math(); //高数 void analyze_Russian(); //俄语 void analyze_Russian_hearing(); //俄语听力 void analyze_professional(); //专业导论 void analyze_politics(); //政治 int cmp(const void *a,const void *b); int cmp1(const void *a,const void *b); //快速排序 int cmp2(const void *a,const void *b); int cmp3(const void *a,const void *b); int cmp4(const void *a,const void *b); int cmp5(const void *a,const void *b); int cmp6(const void *a,const void *b); char _password[18]; passw password_head; int len; void color(short x)//设置颜色 {if(x>=0&&x<=15){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x); }else{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x); }} void HideCursor()//隐藏光标{ CONSOLE_CURSOR_INFO cursor_info = {1, 0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } void toxy(int x, int y)//将光标移动到X,Y坐标处{COORD pos = { x , y }; HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(Out, pos); } int cmp(const void *a,const void *b)//快速排序 {return ((*(Total *)b).sum)-((*(Total *)a).sum); } int cmp1(const void *a,const void *b)//快速排序 {return ((*(Total *)b).c_language)-((*(Total *)a).c_language); } int cmp2(const void *a,const void *b)//快速排序 {return ((*(Total *)b).math)-((*(Total *)a).math); } int cmp3(const void *a,const void *b)//快速排序 {return ((*(Total *)b).Russian)-((*(Total *)a).Russian); } int cmp4(const void *a,const void *b)//快速排序 {return ((*(Total *)b).Russian_hearing)-((*(Total *)a).Russian_hearing); } int cmp5(const void *a,const void *b)//快速排序 {return ((*(Total *)b).professional)-((*(Total *)a).professional); } int cmp6(const void *a,const void *b)//快速排序 {return ((*(Total *)b).politics)-((*(Total *)a).politics); } void menu()//主菜单{do{system("cls"); //清屏 fflush(stdin); //清空缓存 color(14); char t; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(45,7); printf("||"); toxy(45,8); printf("|1.信息录入|"); toxy(45,9); printf("||"); toxy(45,10); printf("|2.信息修改|"); toxy(45,11); printf("||"); toxy(45,12); printf("|3.信息删除|"); toxy(45,13); printf("||"); toxy(45,14); printf("|4.信息显示|"); toxy(45,15); printf("||"); toxy(45,16); printf("|5.信息查找|"); toxy(45,17); printf("||"); toxy(45,18); printf("|6.信息统计|"); toxy(45,19); printf("||"); toxy(45,20); printf("|7.修改密码|"); toxy(45,21); printf("||"); toxy(45,22); printf("|8.退出软件|"); toxy(45,23); printf("--------------------------"); t=getch(); switch(t){case '1':input_information(); break; case '2':amend_information(); break; case '3':delete_information(); break; case '4':print_information(); break; case '5':find_information(); break; case '6':statistics_information(); break; case '7':amend_password(); break; case '8':over(); break; default :break; }}while(1); //永远为真 } passw ff()//将文件中的内容读入链表,返回值为表头地址 {FILE *fp; //文件指针 passw password_head=NULL; fp=fopen("password","a+"); //以追加和读的方式打开名为password的文件 if(fp==NULL){printf("cannot open file"); }//printf("%p\n",password_head); password_head=(passw)malloc(M); //申请空间 strcpy(password_head->password," "); //初始化密码 //printf("%s\n",password_head); fread(password_head,M,1,fp); fclose(fp); //关闭文件 return password_head; //返回值表头地址 } void signin()//登录 {do{system("cls"); color(13); //好看的颜色 passw p,head; int i=0; char k; head=ff(); //调用函数,返回值为表头地址 p=head; //printf("%s\n",p->password); //printf("%p\n",p); char str[]="000000"; //初始密码 toxy(45,6); printf("-----学生档案管理系统-----"); toxy(45,8); printf("请输入管理者密码:"); for(; ; )//此处为输入密码不回显操作 {k=getch(); //输入k if(k=='\r')//如果输入k为回车,则跳出循环 {break; }else if(k=='\b')//如果输入k为删除键 {if(i>0)//如若密码还没完全删除 {printf("\b"); printf(" "); printf("\b"); i--; }}else//如果输入的k既不是删除键,也不是回车键 {_password[i]=k; //把k的值赋给_password[i]; printf("*"); //输出*号,保护用户隐私 i++; //密码位数加1 }}_password[i]='\0'; if(strcmp(p->password," ")==0)//判断程序是否是第一次运行,{strcpy(p->password,str); //如果是,则将初始密码000000赋值给p->password save_password(p); //保存p }if(strcmp(head->password,_password)==0)//判断密码是否输入正确 {system("cls"); toxy(45,8); printf("正在登陆...."); Sleep(500); menu(); }else{toxy(45,10); printf("密码错误!"); Sleep(500); }}while(1); } void amend_password()//修改密码 {system("cls"); //清屏 color(12); //看着舒服的颜色passw p,head; //隐藏光标,看着更舒服 head=ff(); do{ system("cls"); //清屏p=head; char password[18],newpassword[18],t,k; int i=0; toxy(45,6); //将光标移动到坐标为(50,5)的位置 printf("学生档案管理系统"); toxy(48,8); printf("修改密码"); toxy(45,10); printf("请输入旧密码:"); for(; ; )//此处为输入密码不回显操作 {k=getch(); //输入k if(k=='\r')//如果输入k为回车,则跳出循环 {break; }else if(k=='\b')//如果输入k为删除键 {if(i>0)//如若密码还没完全删除 {printf("\b"); printf(" "); printf("\b"); i--; }}else//如果输入的k既不是删除键,也不是回车键 {password[i]=k; //把k的值赋给_password[i]; printf("*"); //输出*号,保护用户隐私 i++; //密码位数加1 }}password[i]='\0'; i=0; toxy(45,12); printf("请输入新密码:"); for(; ; )//此处为输入密码不回显操作 {k=getch(); //输入k if(k=='\r')//如果输入k为回车,则跳出循环 {break; }else if(k=='\b')//如果输入k为删除键 {if(i>0)//如若密码还没完全删除 {printf("\b"); printf(" "); printf("\b"); i--; }}else//如果输入的k既不是删除键,也不是回车键 {newpassword[i]=k; //把k的值赋给_password[i]; printf("*"); //输出*号,保护用户隐私 i++; //密码位数加1 }}newpassword[i]='\0'; if(p!=NULL)//如果p不为空 {if(strcmp(p->password,password)==0)//如果旧密码输入正确 {strcpy(p->password,newpassword); //将旧密码改为新密码 break; //跳出循环 }else//如果旧密码输入错误 {system("cls"); toxy(46,8); printf("--------------------------"); toxy(46,9); printf("||"); toxy(46,10); printf("|密码错误!是否继续?|"); toxy(46,11); printf("||"); toxy(46,12); printf("|1.是2.否|"); toxy(46,13); printf("||"); toxy(46,14); printf("--------------------------"); while(1){t=getch(); //输入t if(t=='1'){system("cls"); break; }else if(t=='2')menu(); }}}}while(1); save_password(p); //永远为真 system("cls"); toxy(45,10); printf("修改成功!即将返回主菜单...."); Sleep(500); menu(); } void save_password(passw p)//将p所指向的内容保存到文件中 {FILE *fp; fp=fopen("password","w"); //以只写的方式打开名为password的文件 if(fp==NULL){printf("cannot open file"); }if(fwrite(p,M,1,fp)!=1)//将p所指向的一段大小为M的内容写入fp所指向的文件中 {printf("write error!"); }fclose(fp); //关闭文件 } Stup ss()//将文件中的内容读出到链表中 {FILE *fp; //文件指针 Stup head=NULL,p,p1,pr=NULL; int n=0; fp=fopen("student","ab+"); if(fp==NULL){printf("cannot open file"); }while(!feof(fp))// feof函数可以检查文件读写位置标志是否移动到文件末尾,feof(fp)检查fp所指向的文件是否结束,如果是{//则函数值为真,否则为假,即“!feof(fp)”为真,在while循环中检查 “!feof(fp)”为真,就执行循环体n++; p=(Stup)malloc(N); //向内存申请一段空间fread(p,N,1,fp); //从fp所指向的文件读入1个大小为M的数据,存储到p所指向的空间中 if(n==1){head=p; p1=p; }else{pr=p1; p1->next=p; p1=p; }}if(pr!=NULL)pr->next=NULL; else if(pr==NULL)head=NULL; fclose(fp); return head; } void input_information()//录入信息 {system("cls"); color(15); int i=0,n; Stup p; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(50,7); printf("信息录入"); toxy(45,8); printf("你需要录入多少个学生的信息?请输入:"); scanf("%d",&n); getchar(); while(i!=n){system("cls"); i++; p=(Stup)malloc(N); toxy(45,6); printf("-----学生档案管理系统-----"); toxy(50,7); printf("信息录入"); toxy(45,8); printf("请输入学生学号:"); gets(p->number); toxy(45,9); printf("请输入学生姓名:"); gets(p->name); toxy(45,10); printf("请输入学生性别(男或女):"); gets(p->sex); toxy(45,11); printf("请输入学生出生日期(年月日,以空格隔开):"); scanf("%d%d%d",&p->birtnday.year,&p->birtnday.month,&p->birtnday.day); getchar(); toxy(45,12); printf("请输入c语言成绩:"); scanf("%f",&p->score.c_language); getchar(); toxy(45,13); printf("请输入高数成绩:"); scanf("%f",&p->score.math); getchar(); toxy(45,14); printf("请输入俄语成绩:"); scanf("%f",&p->score.Russian); getchar(); toxy(45,15); printf("请输入俄语听力成绩:"); scanf("%f",&p->score.Russian_hearing); getchar(); toxy(45,16); printf("请输入专业导论成绩:"); scanf("%f",&p->score.professional); getchar(); toxy(45,17); printf("请输入政治成绩:"); scanf("%f",&p->score.politics); getchar(); toxy(45,18); printf("请输入备注:"); gets(p->remark); save_information(p); }toxy(48,19); printf("录入完毕!按任意键返回主菜单!"); getch(); } void amend_information()//修改信息 {system("cls"); //清屏 color(11); Stup p,head; FILE *fp; int i=15,j=0,c; char number[10]; //学号char name[10],_name[10]; //姓名char sex[2]; //性别int year; //年int month; //月int day; //日float c_language; //c语言float math; //高数float Russian; //俄语float Russian_hearing; //俄语听力float professional; //专业导论float politics; //政治 char remark[100]; //备注char ch,t; head=ss(); p=head; do{system("cls"); toxy(45,6); printf("-----学生档案管理系统-----"); toxy(45,7); printf("修改信息"); toxy(40,9); printf("请输入您要修改的信息:"); gets(_name); toxy(20,8); printf("----------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别出生--日期c语言高 数俄 语俄语听力专业导论政 治备注"); toxy(20,10); printf("----------------------------------------------------------------------------------------------"); i=11; j=0; while(p!=NULL)//将每个结点的p->num都赋为0,以免后面数据干扰 {p->num=0; p=p->next; }p=head; //重新让p指向head while(p!=NULL){if(strcmp(p->name,_name)==0){toxy(18,i); j++; if(p->birtnday.month<10&&p->birtnday.day<10) printf("%d.%s%s%s%d.0%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month<10&&p->birtnday.day>=10)printf("%d.%s%s%s%d.0%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month>=10&&p->birtnday.day<10)printf("%d.%s%s%s%d.%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); elseprintf("%d.%s%s%s%d.%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); i++; p->num=j; //给p->num赋值,即给满足搜索要求的结点编号 }p=p->next; }if(j==0)//如果j=0,即没有进入前面的搜索循环,也就是没有找到相应的信息 { toxy(50,i); printf("没有找到相应的信息!(按0返回,按1重新搜索)"); while(1)//死循环是为了防止除0和1的其他按键干扰 {ch=getch(); if(ch=='0'){menu(); break; }else if(ch=='1'){break; }}if(ch=='1')//如果输入的ch等于1,则结束本次循环 continue; }while(1){toxy(50,i); printf("请输入您要修改的信息的标号:"); scanf("%d",&c); getchar(); i++; if(c<=j)//如果c<=j,即输入正确 break; else if(c>j)//否则,输入错误 {toxy(50,i); printf("没有找到您所要修改的信息,请重新输入!"); i++; Sleep(500); //暂停0.5秒 }}p=head; //让p重新指向head,即第一个结点 while(p!=NULL&&p->num!=c)//遍历链表,寻找满足要求的结点 {p=p->next; }if(p!=NULL)//如果寻找成功,进入修改部分 {system("cls"); //清屏 toxy(45,8); printf("请输入学生学号:"); gets(number); strcpy(p->number,number); toxy(45,9); printf("请输入学生姓名:"); gets(name); strcpy(p->name,name); toxy(45,10); printf("请输入学生性别(男或女):"); gets(sex); strcpy(p->sex,sex); toxy(45,11); printf("请输入学生出生日期(年月日,以空格隔开):"); scanf("%d%d%d",&year,&month,&day); getchar(); p->birtnday.year=year; p->birtnday.month=month; p->birtnday.day=day; toxy(45,12); printf("请输入c语言成绩:"); scanf("%f",&c_language); getchar(); p->score.c_language=c_language; toxy(45,13); printf("请输入高数成绩:"); scanf("%f",&math); getchar(); p->score.math=math; toxy(45,14); printf("请输入俄语成绩:"); scanf("%f",&Russian); getchar(); p->score.Russian=Russian; toxy(45,15); printf("请输入俄语听力成绩:"); scanf("%f",&Russian_hearing); getchar(); p->score.Russian_hearing=Russian_hearing; toxy(45,16); printf("请输入专业导论成绩:"); scanf("%f",&professional); getchar(); p->score.professional=professional; toxy(45,17); printf("请输入政治成绩:"); scanf("%f",&politics); getchar(); p->score.politics=politics; toxy(45,18); printf("请输入备注:"); gets(remark); strcpy(p->remark,remark); toxy(46,16); printf("-------------------------"); toxy(46,17); printf("||"); toxy(46,18); printf("|是否确认修改?|"); toxy(46,19); printf("| 1.确认2.取消 |"); toxy(46,20); printf("||"); toxy(46,21); printf("-------------------------"); while(1)//死循环为防止其他按键干扰 {t=getch(); if(t=='1')break; else if(t=='2'){menu(); }} if(t=='1')//如果t等于1,则跳出循环 {break; }}}while(1); p=head; //p重新指向头节点 system("cls"); toxy(44,12); printf("正在修改...."); fp=fopen("student","wb"); //打开文件的同时清除文件内的内容 if(fp==NULL){printf("cannot open file"); }while(p!=NULL){if(fwrite(p,N,1,fp)!=1)//将p所指向的内容存入fp所指向的文件中 {printf("file write error\n"); }p=p->next; }fclose(fp); //关闭文件 Sleep(500); system("cls"); toxy(44,12); printf("修改成功!正在自动跳转到主菜单...."); Sleep(500); menu(); } void delete_information()//删除信息 {do{system("cls"); color(12); char t; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(48,7); printf("信息删除"); toxy(45,9); printf("1)按学号查询删除"); toxy(45,11); printf("2)按姓名查询删除"); toxy(48,13); printf("按0返回主菜单"); t=getch(); switch(t){case '0':menu(); break; case '1':delete_number(); break; case '2':delete_name(); break; default :break; }}while(1); } void delete_number()//按学号查询删除 {do{system("cls"); color(10); char number[10]; char t,c; int i=11,j=0; Stup head,p,pre=NULL ; FILE *fp; toxy(48,9); printf("请输入你要删除的学生的学号:"); gets(number); head=ss(); p=head; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(20,8); printf("----------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别出生--日期c语言高 数俄 语俄语听力专业导论政 治备注"); toxy(20,10); printf("----------------------------------------------------------------------------------------------"); while(p!=NULL&&strcmp(p->number,number)!=0){pre=p; p=p->next; }if(p!=NULL){toxy(20,i); if(p->birtnday.month<10&&p->birtnday.day<10) printf("%s%s%s%d.0%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month<10&&p->birtnday.day>=10)printf("%s%s%s%d.0%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month>=10&&p->birtnday.day<10)printf("%s%s%s%d.%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); elseprintf("%s%s%s%d.%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); toxy(45,i+1); printf("1.删除2.取消"); while(1){c=getch(); if(c=='1')break; else if(c=='2')delete_number(); }if(pre==NULL)head=head->next; elsepre->next=p->next; system("cls"); toxy(45,10); printf("正在删除...."); p=head->next; fp=fopen("student","wb"); if(fp==NULL){printf("cannot open file"); }if(fwrite(head,N,1,fp)!=1){printf("write error"); } fclose(fp); fp=fopen("student","ab"); if(fp==NULL){printf("cannot open file"); }while(p!=NULL){if(fwrite(p,N,1,fp)!=1){printf("write error"); } p=p->next; }fclose(fp); Sleep(500); system("cls"); toxy(45,10); printf("删除成功!正在返回...."); Sleep(500); delete_information(); }else if(p==NULL){toxy(48,i); printf("您输入的信息不存在!按0返回主菜单,1返回上一级菜单,2重新查找"); while(1){t=getch(); if(t=='0'){menu(); }else if(t=='1'){delete_information(); }else if(t=='2'){break; }}}free(p); }while(1); } void delete_name()//按姓名查询删除 {do{system("cls"); color(10); char name[10]; char t,c; int i=11,j=0,key; Stup head,p,pre; FILE *fp; toxy(48,9); printf("请输入你要删除的学生的姓名:"); gets(name); head=ss(); p=head; while(p!=NULL){p->num=0; p=p->next; }p=head; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(20,8); printf("----------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别出生--日期c语言高 数俄 语俄语听力专业导论政 治备注"); toxy(20,10); printf("----------------------------------------------------------------------------------------------"); while(p!=NULL){if(strcmp(p->name,name)==0){toxy(18,i); j++; if(p->birtnday.month<10&&p->birtnday.day<10) printf("%d.%s%s%s%d.0%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month<10&&p->birtnday.day>=10)printf("%d.%s%s%s%d.0%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month>=10&&p->birtnday.day<10)printf("%d.%s%s%s%d.%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); elseprintf("%d.%s%s%s%d.%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",j,p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); i++; p->num=j; }p=p->next; }if(j==0){toxy(48,i); printf("您输入的信息不存在!按0返回主菜单,1返回上一级菜单,2重新查找"); while(1){t=getch(); if(t=='0'){menu(); }else if(t=='1'){delete_information(); }else if(t=='2'){break; }}if(t=='2')continue; }while(1){toxy(50,i); printf("请输入您要删除的信息的标号:"); scanf("%d",&key); getchar(); i++; if(key<=j)//如果c<=j,即输入正确 break; else if(key>j)//否则,输入错误 {toxy(50,i); printf("没有找到您所要删除的信息,请重新输入!"); i++; Sleep(500); //暂停0.5秒 }}toxy(46,16); printf("-------------------------"); toxy(46,17); printf("||"); toxy(46,18); printf("|确认删除?|"); toxy(46,19); printf("| 1.确认2.取消 |"); toxy(46,20); printf("||"); toxy(46,21); printf("-------------------------"); while(1){p=head; pre=NULL; c=getch(); if(c=='1'){while(p!=NULL&&p->num!=key){pre=p; p=p->next; }if(p!=NULL){if(pre==NULL)head=head->next; elsepre->next=p->next; }free(p); break; }else if(c=='2')delete_number(); }system("cls"); toxy(45,10); printf("正在删除...."); fp=fopen("student","wb"); if(fp==NULL){printf("cannot open file"); }if(head!=NULL&&fwrite(head,N,1,fp)!=1){printf("write error"); } fclose(fp); if(head!=NULL){p=head->next; fp=fopen("student","ab"); if(fp==NULL){printf("cannot open file"); }while(p!=NULL){if(fwrite(p,N,1,fp)!=1){printf("write error"); } p=p->next; }fclose(fp); }Sleep(500); system("cls"); toxy(45,10); printf("删除成功!正在返回...."); Sleep(500); delete_information(); }while(1); } void print_information()//输出信息 {system("cls"); color(11); Stup head,p; int i=11; head=ss(); p=head; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(20,8); printf("----------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别出生--日期c语言高 数俄 语俄语听力专业导论政 治备注"); toxy(20,10); printf("----------------------------------------------------------------------------------------------"); while(p!=NULL){toxy(20,i); if(p->birtnday.month<10&&p->birtnday.day<10) printf("%s%s%s%d.0%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month<10&&p->birtnday.day>=10)printf("%s%s%s%d.0%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month>=10&&p->birtnday.day<10)printf("%s%s%s%d.%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); elseprintf("%s%s%s%d.%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); i++; p=p->next; }toxy(45,i); printf("按任意键返回主菜单!"); getch(); } void find_information()//查找信息 { do{system("cls"); char t; color(10); toxy(45,6); printf("-----学生档案管理系统-----"); toxy(50,7); printf("查找信息"); toxy(48,9); printf("1)学号查询"); toxy(48,11); printf("2)姓名查询"); toxy(48,13); printf("按0返回主菜单"); t=getch(); switch(t){case '0':menu(); break; case '1':find_number_information(); break; case '2':find_name_information(); break; default :break; }}while(1); } void find_number_information()//按学号查找 {do{system("cls"); color(10); char number[10]; char t; int i=11,j=0; Stup head,p; toxy(48,9); printf("请输入你要查找的学生的学号:"); gets(number); head=ss(); p=head; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(20,8); printf("----------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别出生--日期c语言高 数俄 语俄语听力专业导论政 治备注"); toxy(20,10); printf("----------------------------------------------------------------------------------------------"); while(p!=NULL){if(strcmp(p->number,number)==0){toxy(20,i); if(p->birtnday.month<10&&p->birtnday.day<10) printf("%s%s%s%d.0%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month<10&&p->birtnday.day>=10)printf("%s%s%s%d.0%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month>=10&&p->birtnday.day<10)printf("%s%s%s%d.%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); elseprintf("%s%s%s%d.%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); i++; j++; }p=p->next; }if(j==0){toxy(48,i); printf("您输入的信息不存在!"); }toxy(48,i+1); printf("按0继续查找,按1返回"); while(1){t=getch(); if(t=='0'){break; }else if(t=='1'){find_information(); }} }while(1); } void find_name_information()//按姓名查找 {do{system("cls"); color(10); char name[10]; char t; int i=11,j=0; Stup head,p; toxy(48,9); printf("请输入你要查找的学生的姓名:"); gets(name); head=ss(); p=head; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(20,8); printf("----------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别出生--日期c语言高 数俄 语俄语听力专业导论政 治备注"); toxy(20,10); printf("----------------------------------------------------------------------------------------------"); while(p!=NULL){if(strcmp(p->name,name)==0){toxy(20,i); if(p->birtnday.month<10&&p->birtnday.day<10) printf("%s%s%s%d.0%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month<10&&p->birtnday.day>=10)printf("%s%s%s%d.0%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); else if(p->birtnday.month>=10&&p->birtnday.day<10)printf("%s%s%s%d.%d.0%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); elseprintf("%s%s%s%d.%d.%d%.2f%.2f%.2f%.2f%.2f%.2f%s\n",p->number,p->name,p->sex,p->birtnday.year,p->birtnday.month,p->birtnday.day,p->score.c_language,p->score.math,p->score.Russian,p->score.Russian_hearing,p->score.professional,p->score.politics,p->remark); i++; j++; }p=p->next; }if(j==0){toxy(48,i); printf("您输入的信息不存在!"); }toxy(48,i+1); printf("按0继续查找,按1返回"); while(1){t=getch(); if(t=='0'){break; }else if(t=='1'){find_information(); }} }while(1); } void assignment()//将链表的内容赋值给一个结构体数组 {Stup head,p; head=ss(); p=head; int i=0; while(p!=NULL){strcpy(total[i].number,p->number); strcpy(total[i].name,p->name); strcpy(total[i].sex,p->sex); total[i].c_language=p->score.c_language; total[i].math=p->score.math; total[i].Russian=p->score.Russian; total[i].Russian_hearing=p->score.Russian_hearing; total[i].professional=p->score.professional; total[i].politics=p->score.politics; total[i].sum=total[i].c_language+total[i].math+total[i].Russian+total[i].Russian_hearing+total[i].professional+total[i].politics; i++; p=p->next; }len=i; } void statistics_information()//数据统计 {do{system("cls"); color(6); char t; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(50,7); printf("数据统计"); toxy(48,9); printf("1)平均分"); toxy(48,11); printf("2)总分排名"); toxy(48,13); printf("3)各学科不及格人数"); toxy(48,15); printf("4)各科成绩分布分析"); toxy(45,17); printf("按0返回主菜单"); t=getch(); switch(t){case '0':menu(); break; case '1':average_score(); break; case '2':total_score_ranked(); break; case '3':fail_numbers(); break; case '4':grade_table(); break; default :break; }}while(1); } void average_score()//平均分 {system("cls"); color(10); float sum_c=0,sum_math=0,sum_Russian=0,sum_Russian_hearing=0,sum_professional=0,sum_politics=0; float average_c,average_math,average_Russian,average_Russian_hearing,average_professional,average_politics; int i=0; Stup head,p; head=ss(); p=head; while(p!=NULL){sum_c+=p->score.c_language; sum_math+=p->score.math; sum_Russian+=p->score.Russian; sum_Russian_hearing+=p->score.Russian_hearing; sum_professional+=p->score.professional; sum_politics+=p->score.politics; p=p->next; i++; }average_c=sum_c*1.0/i; average_math=sum_math*1.0/i; average_Russian=sum_Russian*1.0/i; average_Russian_hearing=sum_Russian_hearing*1.0/i; average_professional=sum_professional*1.0/i; average_politics=sum_politics*1.0/i; toxy(45,6); printf("-----学生档案管理系统-----"); toxy(48,7); printf("各学科平均分"); toxy(30,8); printf("----------------------------------------------------"); toxy(30,9); printf("c语言高数俄语俄语听力专业导论政治"); toxy(30,10); printf("----------------------------------------------------"); toxy(30,11); printf("%.2f%.2f%.2f%.2f%.2f%.2f",average_c,average_math,average_Russian,average_Russian_hearing,average_professional,average_politics); toxy(45,12); printf("总人数为:%d",i); toxy(50,13); printf("按任意键返回主菜单"); getch(); } void total_score_ranked()//总分排名 {system("cls"); color(10); assignment(); int j,k=11; qsort(total,len,sizeof(Total),cmp); //快速排序 toxy(45,6); printf("-----学生档案管理系统-----"); toxy(48,7); printf("总分排名"); toxy(20,8); printf("--------------------------------------------------------------------------------------------"); toxy(20,9); printf("学号姓名性别c语言高 数俄 语俄语听力专业导论政 治总分名次"); toxy(20,10); printf("--------------------------------------------------------------------------------------------"); for(j=0; j
【C语言实现学生档案管理系统】以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
推荐阅读
- Spring Boot+Vue实现汽车租赁系统(毕设)
- Android技术分享| ViewPager2离屏加载,实现抖音上下视频滑动
- Redis | 第5章 Redis 中的持久化技术《Redis设计与实现》
- [RHCSA学习笔记]Autofs实现自动挂载NFS共享
- JavaScript创建按钮,实现数字自加1
- {调取该文章的TAG关键词}|海归不香了?留学生就业也“两难”
- 集简云 x 海硅企服(助力企业快速满足系统互联需求,轻松实现自动化业务流程!)
- 我给 ”Go 语言“ 开发了 6 个在线工具
- C语言编程基础
- C语言算法