大学生综合评测系统(C语言)
#include <stdio.h> #include <stdlib.h> typedef struct student{ //定义学生信息结构数组 int number; char name[11]; char sex[4]; char adds[15]; char phone[14]; struct student *next; }p,info,swap; typedef struct DATA{ //定义学生数据结构数组 int number; char name[11]; char sex[4]; char adds[15]; char phone[14]; int chinese,math,english,stu,ksmc,pinde,teacher; float aver,ceping; struct DATA *nex; }data,temp; int tolla,count,n; info head=(info)malloc(sizeof(info)); data h=(data)malloc(sizeof(data)); data kopf=(data)malloc(sizeof(data)); void total_yemian(); void info_yemian(); void xuanze(info *head); void info_input(info *head); void info_daoru(info *head); void info_xieru(info *head); void info_xiugai(info *head); void info_del(info *head); void info_chaxun(info head); void info_output(); //写入文件里 void data_yemian(); void data_input(data h); void data_xieru(data h); void data_chaxun(data h); void shuchu(data h); void help(); void xuanze1(info head); void xuanze2(data h); void xuanze3(data h); void data_del(data h); void info_charu(info head); data data_xiugai(data h); data data_daoru(data kopf); void total_yemian() { int choice; system(“color 3E”); system("\ndate/t"); system(“time/t”); printf("\n\n\n\n\n\n\n"); printf("\t\t\t\t\t-------------欢迎来到大学生综合测评系统---------------\n"); printf("\t\t\t-------------|1-学生信息管理系统|2-学生数据处理系统|3-学生综合信息输出----\n"); printf("\t\t\t-------------|4-帮助中心|-------------------|0-退出系统|------------------\n"); printf("\t\t\t----------------------------请输入编号选择--------------------------------\n"); scanf("%d",&choice); printf("\n"); if(choice0){ printf("\t\t☆☆☆☆☆你已经退出,谢谢使用!☆☆☆☆☆\n\n\t\t"); exit(0); } switch(choice){ case 1 : system(“cls”);info_yemian();xuanze(head); break; case 2 : system(“cls”);data_yemian();xuanze2(h); break; case 3 : system(“cls”);shuchu(h);system(“cls”);total_yemian();break; case 4 : system(“cls”);help(); break; default: printf("\n\t输入有误!请重新输入!\n\n"); break; } } void info_yemian() { system(“color 3E”); system("\ndate/t"); system(“time/t”); printf("\n\n\n\n\n\n"); printf("------------------欢迎来到学生信息管理系统--------------\n"); printf("\t\t\t● 1.输入学生信息\n"); printf("\t\t\t● 2.修改学生信息\n"); printf("\t\t\t● 3.删除学生信息\n"); printf("\t\t\t● 4.增加学生信息\n"); printf("\t\t\t● 5.查询学生信息\n"); printf("\t\t\t● 6.保存学生信息\n"); printf("\t\t\t● 7.浏览学生信息\n"); printf("\t\t\t● 0.返回主菜单\n\n"); } void xuanze(info *head){ int choice; printf("\t\t请输入序号选择操作:"); scanf("%d",&choice); if(choice0) { system(“cls”); total_yemian(); } switch(choice){ case 1:system(“cls”); info_input(head);system(“cls”);info_yemian();xuanze1(head);break; case 2:system(“cls”); info_xiugai(head);system(“cls”);info_yemian();xuanze1(head);break; case 3:system(“cls”); info_del(head);system(“cls”);info_yemian();xuanze1(head);break; case 4:system(“cls”); info_charu(head);system(“cls”);info_yemian();xuanze1(head);break; case 5:system(“cls”); info_chaxun(head);system(“cls”);info_yemian();xuanze1(head);break; case 6:system(“cls”); info_xieru(head);system(“cls”);info_yemian();xuanze1(head);break; case 7:system(“cls”); info_output();system(“cls”);info_yemian();xuanze1(head);break; default: printf("\n\t输入有误!请重新输入!\n\n"); break; } } void xuanze1(info head){ int chio; printf("\t\t请输入序号选择操作:"); scanf("%d",&chio); if(chio0) { system(“cls”); total_yemian(); exit(0); } switch(chio){ case 1:system(“cls”);info_input(head);system(“cls”);info_yemian();xuanze1(head);break; case 2:system(“cls”); info_xiugai(head);system(“cls”);info_yemian();xuanze1(head);break; case 3:system(“cls”); info_del(head);system(“cls”);info_yemian();xuanze1(head);break; case 4:system(“cls”); info_charu(head);system(“cls”);info_yemian();xuanze1(head);break; case 5:system(“cls”); info_chaxun(head);system(“cls”);info_yemian();xuanze1(head);break; case 6:system(“cls”); info_xieru(head);system(“cls”);info_yemian();xuanze1(head);break; case 7:system(“cls”); info_output();system(“cls”);info_yemian();xuanze1(head);break; default: printf("\n\t输入有误!请重新输入!\n\n"); break; } } void info_input(info *head) { system(“color 3E”); system("\ndate/t"); system(“time/t”); int n; //第一次counttotal info p,q; printf(“请输入要存储学生信息的个数\n”); scanf("%d",&n); if(n==0) { exit(0); } q=head; printf(“请输入学生的学号,姓名,性别,家庭住址和电话号码\n”); for(int i=0; i<n; i++) { p=(info)malloc(sizeof(info)); scanf("%d%s%s%s%s",&p->number,p->name,p->sex,p->adds,p->phone); q->next=p; p->next=NULL; q=p; } printf("\n输入成功\n"); system(“pause”); } void info_xieru(info head) //写入文件里 { getchar(); FILE f; int i; info p,q; p=head->next; q=head; if((f=fopen(“info.txt”,“w”))NULL) { printf("\n\t打开文件失败!\n\n"); exit(0); } printf(“正在保存中…\n”); while§ { fprintf(f,"\t %d \t\t%s \t\t %s \t\t %s \t\t %s\r\n",p->number,p->name,p->sex,p->adds,p->phone); p=p->next; } fclose(f); printf(“保存成功”); system(“pause”); } void info_xiugai(info *head) { //修改学生信息 info *p,*q; printf("\n输入要修改信息的学号\n"); scanf("%d",&n); p=head->next; q=head; int s; while§ { if(p->numbern) { printf("\t %d \t\t%s \t\t %s \t\t %s \t\t %s\n\n\n",p->number,p->name,p->sex,p->adds,p->phone); printf("\t请输入姓名::"); scanf("%s",p->name); printf("\t请输入性别:"); scanf("%s",p->sex); printf("\t请输入家庭住址::"); scanf("%s",p->adds); printf("\t请输入电话号码:"); scanf("%s",p->phone); printf("\n\t修改成功!\n\n"); } q=p; p=p->next; } p=head->next; printf("---------------------------------------------------\n"); while§ { printf("\t %d \t\t%s \t\t %s \t\t %s \t\t %s\n",p->number,p->name,p->sex,p->adds,p->phone); p=p->next; } system(“pause”); } void info_del(info head) //学生信息删除 { info p,q; printf("\n"); printf(“请输入要删除的学生信息的学号 : “); scanf(”%d”,&n); p=head->next; q=head; while§ { if(np->number) { q->next=p->next; free§; printf(“删除成功\n”); break; } q=p; p=p->next; } p=head->next; printf("---------------------------------------------------\n"); while§ { printf("\t %d \t\t%s \t\t %s \t\t %s \t\t %s\n",p->number,p->name,p->sex,p->adds,p->phone); p=p->next; } system(“pause”); } void info_charu(info *head) { info *p,*q; info node; printf("\n"); printf(“请输入要在哪个学号之后插入信息: “); scanf(”%d”,&n); node=(info)malloc(sizeof(info)); printf(“请输入插入学生的学号,姓名,性别,家庭住址和电话号码\n”); scanf("%d%s%s%s%s",&node->number,node->name,node->sex,node->adds,node->phone); p=head->next; q=head; while(q) { q=p; if(p->numbern) { break; } if(p->numbernode->number){ printf(“输入的学号重复”); system(“pause”); info_charu(head); } p=p->next; } node->next=NULL; node->next=q->next; q->next=node; printf("\n插入成功 “); p=head->next; printf(”---------------------------------------------------\n"); while§ { printf("\t %.0d \t\t%s \t\t %s \t\t %s \t\t %s\n",p->number,p->name,p->sex,p->adds,p->phone); p=p->next; } system(“pause”); } void info_chaxun(info *head) { info *p,*q; p=head->next; q=head; printf("\n请输入要查询信息的学号\n"); scanf("%d",&n); while§ { if(p->numbern){ printf("\t %d \t\t%s \t\t %s \t\t %s \t\t %s\n",p->number,p->name,p->sex,p->adds,p->phone); break; } q=p; p=p->next; } system(“pause”); } void info_output() //学生信息浏览 { FILE f_info; char buF[100]; int i; if((f_info=fopen(“info.txt”,“r”))NULL){ //判断 printf("\n\t没有学生信息!"); printf("\n\n\t\t"); system(“pause”); return; } else{ printf(" \t学号\t\t姓名\t\t性别\t\t家庭住址\t\t联系电话\n"); //输出学生信息 while(fgets(buF,100,f_info)) { printf("%s",buF); } } printf("\n\n\t\t"); system(“pause”); } void data_yemian() //数据处理菜单 { printf("\n\t-------在进入学生数据管理前,请确认学生信息已全部完成!---------\n"); printf("\n\t-------是否继续?输入数字选择(0:返回;其它数字继续。)----------\n"); //清屏 printf("\n\n\n\n\t\t--------学生数据处理系统-----------\n\n"); printf("\t\t\t------------- 1.录入成绩数据-------------\n"); printf("\t\t\t------------- 2.修改学生数据-------------\n"); printf("\t\t\t------------- 3.学生数据保存-------------\n"); printf("\t\t\t------------- 4.学生数据删除-------------\n"); printf("\t\t\t------------- 5.学生数据查询-------------\n"); printf("\t\t\t------------- 0.返回主菜单---------------\n\n"); printf("\t\t请输入序号选择操作:"); } void xuanze2(data *h){ int choice; scanf("%d",&choice); if(choice0) { system(“cls”); total_yemian(); } switch(choice){ case 1: data_input(h);system(“cls”);data_yemian();xuanze3(h);break; case 2: data_xiugai(h);system(“cls”);data_yemian();xuanze3(h);break; case 3: data_xieru(h);system(“cls”);data_yemian();xuanze3(h);break; case 4: data_del(h);system(“cls”);data_yemian();xuanze3(h);break; case 5: data_chaxun(h);system(“cls”);data_yemian();xuanze3(h);break; default: printf("\n\t输入有误!请重新输入!\n\n"); break; } } void xuanze3(data h){ int choice; scanf("%d",&choice); if(choice0) { system(“cls”); total_yemian(); } switch(choice){ case 1: data_input(h);system(“cls”);data_yemian();xuanze3(h);break; case 2: data_xiugai(h);system(“cls”);data_yemian();xuanze3(h);break; case 3: data_xieru(h);system(“cls”);data_yemian();xuanze3(h);break; case 4: data_del(h);system(“cls”);data_yemian();xuanze3(h);break; case 5: data_chaxun(h);system(“cls”);data_yemian();xuanze3(h); break; default: printf("\n\t输入有误!请重新输入!\n\n"); break; } } void data_input(data *h) //数据输入 { FILE *f_info; int choice,i,k; printf("\n\t警告!原有成绩将被覆盖!\n"); printf("\n\t是否继续?输入数字选择(0.返回;其余数字继续)\n\n"); scanf("%d",&choice); if(choice0) { system(“cls”); data_yemian(); } //判断 if((f_info=fopen(“info.txt”,“r”))==NULL){ printf("\n\t打开文件失败!\n\n"); return; } system(“cls”); data p,q,c; q=h; p=h->nex; count=0; data temp={NULL}; while(!feof(f_info)){ p=(data)malloc(sizeof(data)); //导出学生信息 fscanf(f_info,"%d %s %s %s %s “,&p->number,p->name,p->sex,p->adds,p->phone); q->nex=p; p->nex=NULL; q=p; count++; } fclose(f_info); p=h->nex; printf(”\t\t导出学生信息成功,共导出%d条记录。\n\n\n",count); while§ { printf("\t\t%d %s %s %s %s\n “,p->number,p->name,p->sex,p->adds,p->phone); p=p->nex; } p=h->nex; q=h; for(i=0;i<count;i++){ //输入学生数据 printf(”\n\n\n\t\t学号:%.0d 姓名:%s\n",p->number,p->name); printf("\n\t请输入语文成绩:"); scanf("%d",&p->chinese); printf("\t请输入数学成绩:"); scanf("%d",&p->math); printf("\t请输入英语成绩:"); scanf("%d",&p->english); printf("\t请输入同学互评分:"); scanf("%d",&p->stu); printf("\t请输入品德成绩:"); scanf("%d",&p->pinde); printf("\t请输入老师评分:"); scanf("%d",&p->teacher); p->aver=(p->chinese+p->math+p->english)/3.0; p->ceping=(p->aver0.6+p->stu0.1+p->pinde0.1+p->teacher0.2); p=p->nex; q=p; } printf("\n\n输入已完成!正在排名中… \n"); data tail; tail=NULL; while((h->nex->nex)!=tail) { q=h; p=h->nex; while(p->nex!=tail) { if((p->ceping)<(p->nex->ceping)) { q->nex=p->nex; p->nex=p->nex->nex; q->nex->nex=p; p=q->nex; } p=p->nex; q=q->nex; } tail=p; } p=h->nex; i=1; while§ { p->ksmc=i; i++; p=p->nex; } printf(“排名已完成,正在保存中…\n”); data_xieru(h); } void data_xieru(data h) //写入文件函数 { FILE fy; data c,d; int i; if((fy=fopen(“data.txt”,“w”))NULL){ printf("\n\t打开文件失败!\n\n"); exit(0); } c=h->nex; d=h; while?{ fprintf(fy,"\t%d %s %s %s %s %d %d %d %f %d %d %d %d %f\n",c->number,c->name,c->sex,c->adds,c->phone,c->chinese,c->math,c->english,c->aver,c->ksmc,c->stu,c->pinde,c->teacher,c->ceping); c=c->nex; } fclose(fy); printf(“保存学生信息成功\n”); c=h->nex; system(“pause”); } data *data_daoru(data *kopf) { FILE *fy; data c,d; kopf->nex=NULL; count=0; d=kopf; if((fy=fopen(“data.txt”,“r”))==NULL){ printf("\n\t打开文件失败!\n\n"); exit(0); } printf(“正在导入学生信息中…\n”); c=(data)malloc(sizeof(data)); //分配空间 while(!feof(fy)){ c=(data)malloc(sizeof(data)); //分配空间 fscanf(fy,"\t%d %s %s %s %s %d %d %d %f %d %d %d %d %f “,&c->number,c->name,c->sex,c->adds,c->phone,&c->chinese,&c->math,&c->english,&c->aver,&c->ksmc,&c->stu,&c->pinde,&c->teacher,&c->ceping); d->nex=c; c->nex=NULL; d=c; count++; } fclose(fy); printf(”\n\n\t\t"); printf(“导入学生信息成功,共导入%d条记录。\n”,count); c=kopf->nex; d=kopf; system(“pause”); return d; } void data_chaxun(data *h) //数据查询 { int pp; h=data_daoru(kopf); int i; data *c,*d; //导出文件数据 printf("\n\t请输入要查询学生的学号:"); scanf("%d",&pp); c=h->nex; d=h; while? { if(ppc->number) break; c=c->nex; d=c; } printf("\n\t学号:%d 姓名:%s 性别:%s \n\n\t语文:%d 数学:%d 英语:%d 平均成绩:%.1f\n\n\t名次:%d 品德成绩:%d 老师评分:%d 综合成绩:%.1f\n\n",c->number,c->name,c->sex,c->chinese,c->math,c->english,c->aver,c->ksmc,c->pinde,c->teacher,c->ceping); printf("\n\n\t\t"); system(“pause”); system(“cls”); //清屏 } data data_xiugai(data h) //数据修改 { h=data_daoru(kopf); int pp; int i,j,k; data c,d; printf("\n\t请输入要修改学生的学号:"); //这一部分出错了 scanf("%d",&pp); c=h->nex; //这一步没出错 while?{ if(c->numberpp){ break; } c=c->nex; } printf("\n\t学号:%.0ld 姓名:%s \n\n\t语文:%d 数学:%d 英语:%d 同学互评分:%d 品德成绩:%d 老师评分:%d\n\n",c->number,c->name,c->chinese,c->math,c->english,c->stu,c->pinde,c->teacher); printf("\n\t是否修改?\t 1.是 \t 2.否 \t “); //询问 scanf(”%d",&j); system(“cls”); while(1){ if(j1){ printf("\n\t请输入语文成绩:"); scanf("%d",&c->chinese); printf("\t请输入数学成绩:"); scanf("%d",&c->math); printf("\t请输入英语成绩:"); scanf("%d",&c->english); printf("\t请输入同学互评分:"); scanf("%d",&c->stu); printf("\t请输入品德成绩:"); scanf("%d",&c->pinde); printf("\t请输入老师评分:"); scanf("%d",&c->teacher); c->aver=(c->chinese+c->math+c->english)/3.0; c->ceping=(c->aver0.6+c->stu0.1+c->pinde0.1+c->teacher0.2); printf("\n\n\t输入已完成!正在排名中… \n"); system(“pause”); break; } else { data_yemian(); break; } } data tail; tail=NULL; while((h->nex->nex)!=tail) { d=h; c=h->nex; while(c->nex!=tail) { if((c->ceping)<(c->nex->ceping)) { d->nex=c->nex; c->nex=c->nex->nex; d->nex->nex=c; c=d->nex; } c=c->nex; d=d->nex; } tail=c; } c=h->nex; i=1; while? { c->ksmc=i; i++; c=c->nex; } printf(“排名已完成,正在保存中…\n”); data_xieru(h); } void data_del(data h) { h=data_daoru(kopf); data c,d; printf("\n"); printf(“请输入要删除的学生信息的学号 : “); scanf(”%d”,&n); c=h->nex; d=h; printf("%d",c->nex->number); while? { if(n==c->number) { d->nex=c->nex; free?; printf(“删除成功\n”); break; } d=c; c=c->nex; } c=h->nex; printf("---------------------------------------------------\n"); while? { printf("\t%d %s %s %s %s %d %d %d %.1f %d %d %d %d %.1f\n",c->number,c->name,c->sex,c->adds,c->phone,c->chinese,c->math,c->english,c->aver,c->ksmc,c->stu,c->pinde,c->teacher,c->ceping); c=c->nex; } system(“pause”); data_xieru(h); } void shuchu(data h) //学生综合信息输出 { h=data_daoru(kopf); int i; data c; c=h->nex; printf("\t学号\t 姓名\t 性别\t 家庭住址\t 电话号码\t 平均成绩\t 名次\t 综合成绩\n"); while?{ printf("%11.ld %11s %4s %12s %17s %14.1f %9d %9.1f\r\n",c->number,c->name,c->sex,c->adds,c->phone,c->aver,c->ksmc,c->ceping); c=c->nex; } system(“pause”); } void help() //帮助信息 { printf("欢迎使用本系统!\n\n"); printf("本系统可以存储学生的基本信息和各科成绩,并能计算考试平均成绩,综合测评成绩和排名。\n"); printf(“基本信息包括:学号、姓名、性别、家庭住址、联系电话;\n各科成绩包括:语文、数学、外语成绩;\n”); printf("其它包括:考试名次、同学互评分、品德成绩、任课教师评分等。\n"); printf(“说明:考试成绩排名是按照考试成绩计算的(考试成绩=(语+数+外)/3);\n"); printf("综合测评总分=((考试成绩)*0.6+(同学互评分)*0.1+(品德成绩)*0.1+(任课教师评分)*0.2)\n"); printf("其它请按照提示操作即可。***********************************************\n\n”); printf("\n\n\n\n\n\t\t\t\t如有疑问,请联系:QQ:114514\n\n"); printf("\n\n\t\t"); system(“pause”); system(“cls”); total_yemian(); } int main() { system(“pause”); total_yemian(); //调用menu函数 return 0; }
|