本人是大一新生,博客中如哪些代码语言不规范或者代码不整洁,欢迎各位大佬批评指正。也欢迎各位初学者与我一同探讨此系统的优化方向。

1.系统概述

系统大致分为可执行文件与存储数据的txt文件,用户使用不同的账号(共有三个账号)会调用相应的文件,且用户在程序中所作出的录入,删除,修改等功能可在文件中体现出来。
该系统主要有七大功能:录入功能,排序功能,统计功能,查询功能,修改功能,删除功能和切换账号功能。

接下来进入正式的代码介绍

2.变量的定义以及链表的创建

                /*全局变量定义部分*/
char no1[10]="excellent";
char no2[10]="good" ;
char no3[10]="pass";
char no4[10]="fail";
int IDofusers=0;       //用户身份/*结构体部分*/
/*定义学生体侧信息结构体*/
struct student
{char num[20];   //定义学号(可以含字母)char name[20];  //定义名字 char sex[10];   //定义姓别 float weight;   //定义体重 float height;   //定义身高 float BMI;      //定义体重指数int vcp;        //定义肺活量(肺活量的缩写) int count;      //定义仰卧起坐或引体向上个数int score1;     //体重指数成绩 int score2;     //肺活量成绩 int score3;     //引体向上成绩 int scoreAll;   //定义总成绩char level[10]; //定义成绩等级
}stu; /*定义链表结构体*/
struct Node{struct student stu;struct Node *next;
};
//搭建一个链表的基本框架
struct Node* createlist()
{struct Node* headnode=(struct Node*)malloc(sizeof(struct Node)); headnode->next = NULL;return headnode;
}//创建结点
struct Node* createnode(struct student stu)
{struct Node* newnode=(struct Node*)malloc(sizeof(struct Node));newnode->stu = stu;/*将结构体的数据赋值给newnode里的结构体存起来*/newnode->next = NULL;return newnode;
}//插入
void insertnodebyhead(struct Node* headnode,struct student stu)
{struct Node* newnode=createnode(stu);newnode->next=headnode->next;headnode->next=newnode ;}

3.视图部分代码

视图部分代码主要包括了背景设置,登录界面以及菜单栏的打印

/*调背景及字体颜色*/
enum Color
{black, blue, green, lakeBlue, red, purple, yellow, white, gray,lightBlue, lightGreen, lightSimpleGreen, lightRed, lightPurple, lightYellow, brightWhite
};void setColor(unsigned short textColor, unsigned short backColor){char command[9]="color 07";      //默认颜色  command[6]='0'+backColor;       //将backColor变量改为字符型 command[7]='0'+textColor;       //将textColor变量改为字符型 system(command);                //调用系统函数
}
/*视图*/
int userpassword()
{float x,y;for(x=1.3;x>=-1.1;x-=0.1){ for(y=-2;y<=1.4;y+=0.053){if(pow(x*x+y*y-1,3)-x*x*x*y*y<=0){printf("*");Sleep(2);}else{printf(" ");}}printf("\n");}printf("\t\t\t 欢迎进入学生体侧管理系统\n");char  username[20];char  password[20];char  realpassword[3][20];char  realusername[3][20];int cnt,i=0,flag=0;int error=0;/*打开文件*/FILE *fp=fopen("user.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s",realusername[i],realpassword[i]);i++;} cnt=i;printf("\t\t\t 请输入登录账号:");scanf ("%s",username);fflush(stdin);printf("\t\t\t 请输入登录密码:");scanf ("%s",password);fflush(stdin);while(1){for (i=0;i<cnt;i++)if (strcmp(password,realpassword[i])==0&&strcmp(username,realusername[i])==0){printf("\t\t\t 登录成功"); error=0;fclose(fp);return i;}printf("\t\t\t 账号或密码错误,请重新输入\n"); error++;printf("\t\t\t 请输入账号:"); scanf("%s",username);fflush(stdin);printf("\t\t\t 请输入密码:");scanf("%s",password);fflush(stdin);  if (error==3)  {printf("\t\t\t\t多次错误输入,无法打开");fclose(fp);exit(1);}}
}void mainmenu()                                    //主菜单视图
{system("cls");printf("                        --------------学生体测成绩判定系统功能菜单------------\n");printf("                        |      \t\t0. 退出系统                          |\n");printf("                        |      \t\t1. 学生体侧成绩录入                  |\n");printf("                        |      \t\t2. 学生体侧成绩排序                  |\n");printf("                        |      \t\t3. 学生体侧成绩统计                  |\n");printf("                        |      \t\t4. 学生体侧成绩查询                  |\n");printf("                        |      \t\t5. 学生体侧成绩修改                  |\n");printf("                        |      \t\t6. 学生体侧成绩删除                  |\n");printf("                        |      \t\t7. 切换账号                          |\n");printf("                        ------------------------------------------------------\n");
}void keydown(struct Node *list)                   //按键交互
{int choose;    //choose为功能选择 printf("\n请输入您需要的功能(0~~7): ");scanf("%d", &choose);choose=choiceinput(choose,0,7);switch (choose) {case 0:printf("退出系统确认提示\n"); int ret;ret=MessageBox(NULL, TEXT("请问是否退出系统?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==1) {printf("系统已关闭,感谢您的使用!");exit(0);}else {mainmenu();keydown(list); }break;case 1:printf("\t\t 欢迎使用[成绩录入]功能\n");input(list);  break;case 2:printf("\t\t 欢迎使用[成绩排序]功能\n");range(list);break;case 3:printf("\t\t 欢迎使用[成绩统计]功能\n");printlist(list);break;case 4:printf("\t\t  欢迎使用[成绩查询]功能\n");search(list); break;case 5:printf("\t\t 欢迎使用[成绩修改]功能\n");alter(list); break;case 6:printf("\t\t 欢迎使用[成绩删除]功能\n");deleted(list); break;case 7:printf("\t\t 欢迎使用[切换账号]功能\n");changeuser(list);free(list);struct Node *list = createlist(); switch(IDofusers){case 1: filescanf1(list); break;  //将文件中的数据初始化进链表中case 2: filescanf2(list); break;case 3: filescanf3(list); break;}mainmenu();keydown(list);}
}

4.具体功能实现代码

/*功能一:录入成绩主函数*/
void input(struct Node *list)
{while (1){int ten; printf("\n请输入学生的学号:\n");scanf("%s",stu.num);judgestunum(list);             //判断学号长度与学号是否会出现重复 printf("请输入学生的姓名:\n");scanf("%s",stu.name);printf("请输入学生的性别(man或woman):\n");scanf("%s",stu.sex);fflush(stdin);printf("请输入学生的体重(单位:kg):\n");scanf("%f",&stu.weight);printf("请输入学生的身高(单位:米):\n");scanf("%f",&stu.height);printf("请输入学生的肺活量:\n");scanf("%d",&stu.vcp);while (1){if (sexjudge(stu.sex)==1)                    //判断性别 {printf("请输入学生的引体向上的个数:\n");scanf("%d",&stu.count);break; }else if (sexjudge(stu.sex)==2){printf("请输入学生的仰卧起坐的个数:\n");scanf("%d",&stu.count);break; }else {printf("性别输入错误,请重新输入该学生的性别(man或woman):");scanf("%s",stu.sex);fflush(stdin);}} stu=inputscore(stu);                                   //将数据转换为成绩并存储起来 insertnodebyhead(list,stu);  switch(IDofusers) {case 1: fileprint1(list); break;                   //将链表中的数据读进链表中case 2: fileprint2(list); break;case 3: fileprint3(list); break;}//把文件中的数据读到文件中 int ret=MessageBox(NULL, TEXT("请问是否继续录入?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2)                                           //输入“否”键将退出循环 {break;} }printf("录入成功,2秒后将退出");sleep(2); mainmenu();keydown(list);
} //判断输入的学号输入的正确性
void judgestunum(struct Node* list){struct Node *pr=list->next;int length;int ret;while (1){ret=1;pr=list->next;length=strlen(stu.num);if (length!=9){printf("输入长度错误,请重新输入(学号为9位):");scanf("%s",stu.num);continue;}while (pr){if (strcmp(stu.num,pr->stu.num)==0){printf("该学号已经存在,请重新输入:"); ret=0;scanf("%s",stu.num);break;}pr=pr->next;    }if (ret)  break;}free(pr);
} //将数据转换为成绩
struct student inputscore(struct student info) {//体重指数分数计算 info.BMI=info.weight/pow(info.height,2);if (info.BMI>=17.9&&info.BMI<=23.9){info.score1=100;}else if(info.BMI<17.9||(info.BMI>=24.0&&info.BMI<=27.9)){info.score1=80;}else info.score1=60;//肺活量分数计算if (sexjudge(info.sex)==1)       //性别判定为男{if (info.vcp>=4800) info.score2=100;else if (info.vcp<4800&&info.vcp>=4181)  info.score2=80;else if (info.vcp>=3101&&info.vcp<=4180) info.score2=60;else info.score2=30;} else if (sexjudge(info.sex)==2)  //性别判定为女 {if (info.vcp>=3400) info.score2=100;else if (info.vcp<3400&&info.vcp>3000)  info.score2=80;else if (info.vcp>=2051&&info.vcp<=3000) info.score2=60;else info.score2=30;} //引体向上和 仰卧起分数判断if (sexjudge(info.sex)==2)      //性别判定为女 {if (info.count>=56) info.score3=100;else if (info.count<56&&info.count>=53)  info.score3=80;else if (info.count>=25&&info.count<=52) info.score3=60;else info.score3=30;} else if (sexjudge(info.sex)==1)  //性别判定为男 {if (info.count>=19) info.score3=100;else if (info.count<19&&info.count>=16)  info.score3=80;else if (info.count>=10&&info.count<=15) info.score3=60;else info.score3=30;} info.scoreAll = (float)info.score1*0.25+(float)info.score2*0.35+(float)info.score3*0.4;//等级判定if (info.scoreAll>=95)  strcpy(info.level,no1);else if (info.scoreAll>=80&&info.scoreAll<=94)  strcpy(info.level,no2);else if (info.scoreAll>=60&&info.scoreAll<=79)  strcpy(info.level,no3);else strcpy(info.level,no4);return info; }/*功能二:排序主函数*/
void range(struct Node *headnode)
{printf("\n请问您想选择哪种排序方式(学号排序输入1,姓名排序输入2,分数排序输入3):");int n;scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,3);switch(n){case 1:rangebynum(headnode);break;case 2:rangebyname(headnode);break;case 3:rangebyscore(headnode);break; } print();struct Node *p=headnode->next;while (p){printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.BMI,p->stu.vcp,p->stu.count,p->stu.scoreAll,p->stu.level);p=p->next;}printline();                           //打印下划线,构成图表 printf ("\n输入回车键返回主菜单:");getchar();mainmenu();keydown(headnode);
} void rangebyname(struct Node* headnode)  //姓名排序
{int i;struct student msg;struct Node *p=headnode->next;struct Node *q=headnode;for (i=1;i<=20;i++){while(p->next){if (strcmp(p->stu.name,p->next->stu.name)<0){msg=p->stu;p->stu = p->next->stu;p->next->stu=msg;}p=p->next;}p=q->next;}
} void rangebynum(struct Node* headnode)  //学号排序
{int i;struct student msg;struct Node *p=headnode->next;struct Node *q=headnode;for (i=1;i<=20;i++){while(p->next){if (strcmp(p->stu.num,p->next->stu.num)>0){msg=p->stu;p->stu = p->next->stu;p->next->stu=msg;}p=p->next;}p=q->next;}
} void rangebyscore(struct Node* headnode)   //分数排序
{int i;struct student msg;struct Node *p=headnode->next;struct Node *q=headnode;for (i=1;i<=20;i++){while(p->next){if (p->stu.scoreAll >  p->next->stu.scoreAll){msg=p->stu;p->stu = p->next->stu;p->next->stu=msg;}p=p->next;}p=q->next;}
} /*功能三:统计功能主函数*/
void printlist(struct Node* headnode) //遍历
{struct Node *p=headnode->next;int allnumber=0;float averagescore1=0,averagescore2=0,averagescore3=0;float averagescoreAll=0;printf("这是已录入的学生体侧成绩\n");print(); while (p){//      printf("%-15s%-8s%-5s%-5.1f%-7.2f%-8d%-3d\n",p->stu.num,p->stu.name,p->stu.sex,
//              p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count);
//上面是数据,下面是成绩 printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.BMI,p->stu.vcp,p->stu.count,p->stu.scoreAll,p->stu.level);averagescore1+=p->stu.score1;averagescore2+=p->stu.score2;averagescore3+=p->stu.score3;averagescoreAll+=p->stu.scoreAll;p=p->next;allnumber++;}printline();printf("\n");averagescore1/=allnumber;averagescore2/=allnumber;averagescore3/=allnumber;averagescoreAll/=allnumber;printf("现在已经录入了%d个学生的成绩\n",allnumber);printf("\n分数数据概况:\n"); printf("体重指数平均分为%.1f,肺活量平均分为%.1f,引体向上和仰卧起坐的平均分为%.1f,总分的平均分为%.1f\n",averagescore1,averagescore2,averagescore3,averagescoreAll);int staticvcps[3]={0,0,0};  //定义了数组来放vcp的最大值,最小值与平均值      staticvcp(headnode,allnumber,staticvcps);printf("\n本班学生肺活量最高值是%d,最低值是%d,平均值是%d\n",staticvcps[0],staticvcps[1],staticvcps[2]);int staticcounts[6]={0,0,0,0,0,0};  staticcount(headnode,allnumber,staticcounts);printf("本班学生引体向上最高值是%d,最低值是%d,平均值是%d\n",staticcounts[0],staticcounts[1],staticcounts[2]);float staticBMIs[3]={0,0,0};staticBMI(headnode,allnumber,staticBMIs);printf("本班学生体重指数最高值是%.1f,最低值是%.1f,平均值是%.1f\n",staticBMIs[0],staticBMIs[1],staticBMIs[2]);int staticscores[8]={0,0,0,0,0,0,0,0};scorelevel(headnode,allnumber,staticscores);printf("\n本班男生评价为excellent的有%d人,评价为good有%d人,评价为pass的有%d人,评价为fail的有%d人\n" ,staticscores[0],staticscores[1],staticscores[2],staticscores[3]);printf("本班女生评价为excellent的有%d人,评价为good有%d人,评价为pass的有%d人,评价为fail的有%d人\n" ,staticscores[4],staticscores[5],staticscores[6],staticscores[7]);    getchar();printf ("\n统计结束,输入回车键返回主菜单:");getchar();mainmenu();keydown(headnode);
}/*各项数据统计细则*/
void staticvcp (struct Node* headnode,int n,int *vcps)    //vcp统计
{struct Node *p=headnode->next;vcps[1]=p->stu.vcp; while (p){if (vcps[0] < p->stu.vcp)  vcps[0]=p->stu.vcp;  //0存最高值 if (vcps[1] > p->stu.vcp)  vcps[1]=p->stu.vcp;  //1存最小值 vcps[2] += p->stu.vcp;                          //2存平均值 p=p->next;}vcps[2]/=n;}void staticcount (struct Node* headnode,int n,int *counts)   //仰卧起坐,引体向上数据统计
{struct Node *p=headnode->next;int cnt=0,cntt=0;while (p){if (sexjudge(p->stu.sex)==1){if (cnt==0)   counts[1]=p->stu.count;                      //给count赋初值,防止最小值显示为1 if (counts[0] < p->stu.count)  counts[0]=p->stu.count;if (counts[1] > p->stu.count)  counts[1]=p->stu.count;counts[2]+=p->stu.vcp;cnt++;}else if (sexjudge(p->stu.sex)==2){                           if (cntt==0)  counts[4]=p->stu.count;                      //给count赋初值,防止最小值显示为1if (counts[3] < p->stu.count)  counts[3]=p->stu.count;if (counts[4] > p->stu.count)  counts[4]=p->stu.count;counts[5]+=p->stu.vcp;cntt++;}p=p->next;}counts[2]/=n;
}void staticBMI(struct Node* headnode,int n,float *BMIs)   //BMI数据统计
{struct Node *p=headnode->next;BMIs[1]=p->stu.BMI; while (p){if (BMIs[0] < p->stu.BMI)  BMIs[0]=p->stu.BMI;   //0存最高值 if (BMIs[1] > p->stu.BMI)  BMIs[1]=p->stu.BMI;   //1存最小值 BMIs[2] += p->stu.BMI;                           //2存平均值 p=p->next;}BMIs[2]/=n;
}void scorelevel(struct Node* headnode,int n,int *scores) //score有8个值,前4个男生,后四个女生
{struct Node *p=headnode->next;while (p){if (sexjudge(p->stu.sex)==1){if (strcmp(p->stu.level,no1)==0) scores[0]++;else if (strcmp(p->stu.level,no2)==0) scores[1]++;else if (strcmp(p->stu.level,no3)==0) scores[2]++;else if (strcmp(p->stu.level,no4)==0) scores[3]++;}else if (sexjudge(p->stu.sex)==2){if (strcmp(p->stu.level,no1)==0) scores[4]++;else if (strcmp(p->stu.level,no2)==0) scores[5]++;else if (strcmp(p->stu.level,no3)==0) scores[6]++;else if (strcmp(p->stu.level,no4)==0) scores[7]++;} p=p->next;}} /*功能四:查询某人成绩*/
void search (struct Node* headnode)
{while (1){printf("\n请问您是使用姓名查询,学号查询还是分数查询(学号查询输入1,姓名查询输入2,分数查询输入3):");int n;char searchnum[20];char searchname[10]; int searchscore;scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,3); switch(n){case 1:printf("\n请输入您要查询学生的学号:");scanf("%s",searchnum);searchbynum(headnode,searchnum);break;case 2:printf("\n请输入您要查询学生的姓名:");scanf("%s",searchname);searchbyname(headnode,searchname);break;case 3:printf("\n请输入您要查询学生的分数:");scanf("%d",&searchscore);searchbyscore(headnode,searchscore);break; }getchar();int ret;ret=MessageBox(NULL, TEXT("请问是否需要继续查询?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2) break; }printf ("\n查询结束,输入回车键返回主菜单:");getchar(); mainmenu();keydown(headnode);
} void searchbynum(struct Node* headnode,char searchnum[])  //根据学号找人的函数
{printf("\n");char a; struct Node* searchnode = headnode->next;if (searchnode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(searchnode->stu.num,searchnum)!=0){searchnode=searchnode->next;if (searchnode==NULL){printf("没有找到该学生的相关消息\n");break;}}  }if (searchnode!=NULL){print(); printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",searchnode->stu.num,searchnode->stu.name,searchnode->stu.sex,searchnode->stu.BMI,searchnode->stu.vcp,searchnode->stu.count,searchnode->stu.scoreAll,searchnode->stu.level);printline();getchar();printf("\n若对该学生分数有疑惑,输入y可查看具体分数细则,若无疑惑输入任意字符:");scanf("%c",&a); if (a=='y'){if (sexjudge(searchnode->stu.sex)==1){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 引体向上分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,引体向上个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }else if (sexjudge(searchnode->stu.sex)==2){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 仰卧起坐分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,仰卧起坐个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }printf("所以%d * 0.25 + %d * 0.35 + %d * 0.4 = %d",searchnode->stu.score1,searchnode->stu.score2,searchnode->stu.score3,searchnode->stu.scoreAll);}}} void searchbyname(struct Node* headnode,char searchname[])   //根据姓名找人的函数
{printf("\n");char a;struct Node* searchnode = headnode->next;if (searchnode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(searchnode->stu.name,searchname)!=0){searchnode=searchnode->next;if (searchnode==NULL){printf("没有找到该学生的相关消息\n");break;}} }if (searchnode!=NULL){print() ;printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",searchnode->stu.num,searchnode->stu.name,searchnode->stu.sex,searchnode->stu.BMI,searchnode->stu.vcp,searchnode->stu.count,searchnode->stu.scoreAll,searchnode->stu.level);printline();getchar();printf("\n若对该学生分数有疑惑,输入y可查看具体分数细则,若无疑惑输入任意字符:");scanf("%c",&a); if (a=='y'){if (sexjudge(searchnode->stu.sex)==1){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 引体向上分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,引体向上个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }else if (sexjudge(searchnode->stu.sex)==2){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 仰卧起坐分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,仰卧起坐个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }printf("所以%d * 0.25 + %d * 0.35 + %d * 0.4 = %d",searchnode->stu.score1,searchnode->stu.score2,searchnode->stu.score3,searchnode->stu.scoreAll);}}
}void searchbyscore(struct Node* headnode,int searchscore)   //根据分数找人的函数
{printf("\n");struct Node* searchnode = headnode->next;int cnt=0;if (searchnode==NULL){printf("您还未录入任何人的信息\n"); }else{while (searchnode){if (searchnode->stu.scoreAll==searchscore){cnt++;if (cnt==1)  print() ; printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",searchnode->stu.num,searchnode->stu.name,searchnode->stu.sex,searchnode->stu.BMI,searchnode->stu.vcp,searchnode->stu.count,searchnode->stu.scoreAll,searchnode->stu.level);}searchnode=searchnode->next;}  }if (cnt==0){printf("本班无学生分数为%d\n",searchscore);}else printline();
}/*功能五:修改某人成绩*/
void alter (struct Node* headnode)  //根据学号找人的函数
{while(1){printf("请输入所修改信息的学生的姓名或学号(学号输入1,姓名输入2):");int n;char alternum[20];char altername[10]; scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,2);switch(n){case 1:printf("\n请输入您要修改的学生的学号:");scanf("%s",alternum);alterbynum(headnode,alternum);break;case 2:printf("\n请输入您要修改的学生的姓名:");scanf("%s",altername);alterbyname(headnode,altername);break;} switch(IDofusers) {case 1: fileprint1(headnode); break;                   //将链表中的数据读进链表中case 2: fileprint2(headnode); break;case 3: fileprint3(headnode); break;}int ret;ret=MessageBox(NULL, TEXT("请问是否继续使用修改功能?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2) break;}printf ("\n修改结束,输入回车键返回主菜单:");getchar();mainmenu();keydown(headnode);
} void alterbynum(struct Node* headnode,char alternum[])  //根据学号找人的函数
{struct Node* alternode = headnode->next;if (alternode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(alternode->stu.num,alternum)!=0){alternode=alternode->next;if (alternode==NULL){printf("没有找到该学生的相关消息\n");break;}}    }if (alternode!=NULL){printf("这是修改前学生的成绩:\n"); print() ; printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",alternode->stu.num,alternode->stu.name,alternode->stu.sex,alternode->stu.BMI,alternode->stu.vcp,alternode->stu.count,alternode->stu.scoreAll,alternode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认修改该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1)  alterprocess(alternode);else if (n==2) printf("\n结束修改该学生信息的操作");}
} void alterbyname(struct Node* headnode,char altername[])   //根据姓名找人的函数
{struct Node* alternode = headnode->next;if (alternode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(alternode->stu.name,altername)!=0){alternode=alternode->next;if (alternode==NULL){printf("没有找到该学生的相关消息\n");break;}}  }if (alternode!=NULL){printf("这是修改前学生的信息:\n"); print() ;printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",alternode->stu.num,alternode->stu.name,alternode->stu.sex,alternode->stu.BMI,alternode->stu.vcp,alternode->stu.count,alternode->stu.scoreAll,alternode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认修改该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1)  alterprocess(alternode);else if (n==2) printf("\n结束修改该学生信息的操作");}
}void alterprocess(struct Node* alternode)
{printf("\n请问您要修改哪项数据(体重输入1,身高输入2,肺活量输入3,引体向上输入4):");int n;scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,4);printf("\n您将此数据修改为:");int afteralter1;float afteralter2;switch (n){case 1:scanf("%f",&afteralter2);fflush(stdin);alternode->stu.weight=afteralter2;break;case 2:scanf("%f",&afteralter2);fflush(stdin);alternode->stu.height=afteralter2;break;case 3:scanf("%d",&afteralter1);fflush(stdin);alternode->stu.vcp=afteralter1;break;case 4:scanf("%d",&afteralter1);fflush(stdin); alternode->stu.count=afteralter1;break;}printf("\n这是修改后学生的信息:\n"); alternode->stu=inputscore(alternode->stu); print() ;printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",alternode->stu.num,alternode->stu.name,alternode->stu.sex,alternode->stu.BMI,alternode->stu.vcp,alternode->stu.count,alternode->stu.scoreAll,alternode->stu.level);printline();
} /*功能六:删除功能的主函数*/
void deleted(struct Node* headnode)
{while(1){printf("\n请问您是选择输入姓名删除还是输入学号删除(选择学号输入1,选择姓名输入2):") ;int n;char deletenum[20];char deletename[10]; scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,3);switch(n){case 1:printf("请输入您所要删除的学生的学号:");scanf("%s",deletenum);deletebynum(headnode,deletenum);break;case 2:printf("请输入您所要删除学生的姓名:");scanf("%s",deletename);deletebyname(headnode,deletename);break;} switch(IDofusers) {case 1: fileprint1(headnode); break;                   //将链表中的数据读进链表中case 2: fileprint2(headnode); break;case 3: fileprint3(headnode); break;}Sleep(1);int ret;ret=MessageBox(NULL, TEXT("请问是否继续使用删除功能?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2) break;}mainmenu();keydown(headnode);
}void  deletebynum(struct Node* headnode,char posnum[])  //根据学号删除
{int n;int cnt=0; struct Node* posnode = headnode->next;struct Node* posnodeFront=headnode;if (posnode==NULL){printf("无法删除,链表为空\n"); }else{while (strcmp(posnode->stu.num,posnum)!=0){posnodeFront=posnode;posnode=posnode->next;if (posnode==NULL){printf("没有找到该学生,请确定输入是否正确\n");cnt=1;break;}}  }if (cnt==0){printf("这是要删除学生的数据\n");print();printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",posnode->stu.num,posnode->stu.name,posnode->stu.sex,posnode->stu.BMI,posnode->stu.vcp,posnode->stu.count,posnode->stu.scoreAll,posnode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认删除该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1){posnodeFront->next=posnode->next;free(posnode);printf("删除成功\n");}else {printf("已经放弃删除\n");} }
}void  deletebyname(struct Node* headnode,char posname[])  //根据姓名删除
{int cnt=0;struct Node* posnode = headnode->next;struct Node* posnodeFront=headnode;if (posnode==NULL){printf("无法删除,信息表为空\n"); }else{while (strcmp(posnode->stu.name,posname)!=0){posnodeFront=posnode;posnode=posnode->next;if (posnode==NULL){printf("没有找到该学生,请确定输入是否正确\n");cnt=1;break;}}  }if (cnt==0){printf("这是要删除学生的数据\n");print();printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",posnode->stu.num,posnode->stu.name,posnode->stu.sex,posnode->stu.BMI,posnode->stu.vcp,posnode->stu.count,posnode->stu.scoreAll,posnode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认删除该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1){posnodeFront->next=posnode->next;free(posnode);printf("删除成功\n");}else {printf("已经放弃删除\n");} }
}/*功能七:切换账号*/
void changeuser(struct Node* headnode)
{char  username[20];char  password[20];char  realpassword[3][20];char  realusername[3][20];int cnt,i=0,error=0,flag=0;/*打开文件*/FILE *fp=fopen("user.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s",realusername[i],realpassword[i]);i++;} cnt=i;printf("\t\t\t 请输入账号:");scanf ("%s",username);fflush(stdin);printf("\t\t\t 请输入密码:");scanf ("%s",password);fflush(stdin);while(1){for (i=0;i<cnt;i++)if (strcmp(password,realpassword[i])==0&&strcmp(username,realusername[i])==0){printf("\t\t\t 切换成功");IDofusers = i+1;flag=1;fclose(fp);break;}if (flag==0){printf("\t\t\t 账号或密码错误,请重新输入\n"); error++;printf("\t\t\t 请输入账号:"); scanf("%s",username);fflush(stdin);printf("\t\t\t 请输入密码:");scanf("%s",password);fflush(stdin);    if (error==3)  {printf("\t\t\t\t多次错误输入,切换失败");fclose(fp);}}else {break;}}
}
/*文件读写部分*/
/*从文件中读内容*/
void filescanf1(struct Node* headnode)
{FILE *fp=fopen("test1.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s %s %f %f %d %d",stu.num,stu.name,stu.sex,&stu.weight,&stu.height, &stu.vcp, &stu.count);stu=inputscore(stu);insertnodebyhead(headnode,stu);} fclose(fp);
} void filescanf2(struct Node* headnode)
{FILE *fp=fopen("test2.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s %s %f %f %d %d",stu.num,stu.name,stu.sex,&stu.weight,&stu.height, &stu.vcp, &stu.count);stu=inputscore(stu);insertnodebyhead(headnode,stu);} fclose(fp);
}void filescanf3(struct Node* headnode)
{FILE *fp=fopen("test3.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s %s %f %f %d %d",stu.num,stu.name,stu.sex,&stu.weight,&stu.height, &stu.vcp, &stu.count);stu=inputscore(stu);insertnodebyhead(headnode,stu);} fclose(fp);
}  /*读内容给文件*/
void fileprint1(struct Node* headnode)
{FILE *fp=fopen("test1.txt","w");if(fp == NULL){printf("无法打开文件\n");}struct Node* p=headnode->next;while (p) {fprintf(fp,"\n");fprintf(fp,"%s %s %s %.1f %.2f %d %d",p->stu.num,p->stu.name,p->stu.sex,p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count) ;p=p->next;}fclose(fp);
} void fileprint2(struct Node* headnode)
{FILE *fp=fopen("test2.txt","w");if(fp == NULL){printf("无法打开文件\n");}struct Node* p=headnode->next;while (p) {fprintf(fp,"\n");fprintf(fp,"%s %s %s %.1f %.2f %d %d",p->stu.num,p->stu.name,p->stu.sex,p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count) ;p=p->next;}fclose(fp);
} void fileprint3(struct Node* headnode)
{FILE *fp=fopen("test3.txt","w");if(fp == NULL){printf("无法打开文件\n");}struct Node* p=headnode->next;while (p) {fprintf(fp,"\n");fprintf(fp,"%s %s %s %.1f %.2f %d %d",p->stu.num,p->stu.name,p->stu.sex,p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count) ;p=p->next;}fclose(fp);
} 

5.辅助函数

void print(){printf("______________________________________________________________________________________________\n");printf("|  学号    |   姓名  | 性别 | 体重指数 | 肺活量 | 引体向上/仰卧起坐个数 | 总分数 |  成绩等级  |\n") ;
}
void printline(){printf("|_____________________________________________________________________________________________|\n");
}//判断输入合法性
int choiceinput(int choose,int m,int n){while (choose > n || choose < m) {printf("您输入了一个无效的选择,请重新输入: ");scanf("%d", &choose);}return choose;
}//判断性别函数
int sexjudge(char sex[]){int a;char man[4]="man";char woman[6]="woman";if (strcmp(sex,man)==0){a=1; }else if (strcmp(sex,woman)==0){a=2;            }else a=3;return a;
}

6.完整代码展示

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<math.h>/*全局变量定义部分*/
char no1[10]="excellent";
char no2[10]="good" ;
char no3[10]="pass";
char no4[10]="fail";/*结构体部分*/
/*定义学生体侧信息结构体*/
struct student
{char num[20];   //定义学号(可以含字母)char name[20];  //定义名字 char sex[10];   //定义姓别 float weight;   //定义体重 float height;   //定义身高 float BMI;      //定义体重指数int vcp;        //定义肺活量(肺活量的缩写) int count;      //定义仰卧起坐或引体向上个数int score1;     //体重指数成绩 int score2;     //肺活量成绩 int score3;     //引体向上成绩 int scoreAll;   //定义总成绩char level[10]; //定义成绩等级
}stu; /*定义链表结构体*/
struct Node{struct student stu;struct Node *next;
};/*声明函数部分*/
/*视图*/
void mainmenu();                             //主菜单视图
void keydown(struct Node *list);             //按键交互
int userpassword();                          //登录验证是否存在此人
void setColor(unsigned short textColor, unsigned short backColor); //背景/*链表*/
struct Node* createlist();
struct Node* createnode(struct student stu);
void insertnodebyhead(struct Node* headnode,struct student stu);/*辅助函数*/
int sexjudge(char sex[]) ;                                       //性别判断辅助函数
int choiceinput(int choice,int m,int n);                         //判断选择输入的正确性
void judgestunum(struct Node* list);                             //判断学号
void print();                                                    //打印基本信息
void printline();/*功能一:录入成绩*/
void input(struct Node *list);                      //录入成绩的总函数
struct student inputscore(struct student info);     //将数据转换为成绩的函数 /*功能二:成绩排序*/
void range(struct Node* headnode) ;
void rangebyname(struct Node* headnode);
void rangebynum(struct Node* headnode);
void rangebyscore(struct Node* headnode);     /*功能三:统计成绩*/
void printlist(struct Node* headnode);                       //打印所有人的成绩
void staticBMI(struct Node* headnode,int n,float *BMIs);     //体重指数函数
void staticvcp (struct Node* headnode,int n,int *vcps);      //肺活量函数
void staticcount (struct Node* headnode,int n,int *counts);  //引体向上或仰卧起坐个数
void scorelevel(struct Node* headnode,int n,int *scores);    //分数段统计 /*功能四:查询某人成绩*/
void search (struct Node* headnode) ;
void searchbynum(struct Node* headnode,char searchnum[]);    //通过学号查询
void searchbyname(struct Node* headnode,char searchname[]);  //通过姓名查询
void searchbyscore(struct Node* headnode,int searchscore);   //通过分数查询 /*功能五:修改功能*/
void alter(struct Node* headnode);
void alterbynum(struct Node* headnode,char alternum[]);
void alterbyname(struct Node* headnode,char altername[]);
void alterprocess(struct Node* alternode);/*功能六:删除功能*/
void deleted(struct Node* headnode);
void deletebynum (struct Node* headnode,char posnum[]);
void deletebyname (struct Node* headnode,char posname[]);/*功能七:切换账号*/
void changeuser(struct Node* headnode);
void filescanf1(struct Node* headnode);                           //文件读入
void filescanf2(struct Node* headnode);
void filescanf3(struct Node* headnode);
void fileprint1(struct Node* headnode);                          //读入文件
void fileprint2(struct Node* headnode);
void fileprint3(struct Node* headnode);                          int IDofusers=0;       //用户身份 int main()
{setColor(1,7);                      //渲染页面 IDofusers=userpassword()+1;         //判断该管理员身份mainmenu();                         //主菜单视图struct Node *list = createlist();   //createlist返回值为headnode在堆栈中的地址 switch(IDofusers) {case 1: filescanf1(list); break;        //将文件中的数据初始化进链表中case 2: filescanf2(list); break;case 3: filescanf3(list); break;}keydown(list);                      //按键交互
}/*调背景及字体颜色*/
enum Color
{black, blue, green, lakeBlue, red, purple, yellow, white, gray,lightBlue, lightGreen, lightSimpleGreen, lightRed, lightPurple, lightYellow, brightWhite
};void setColor(unsigned short textColor, unsigned short backColor){char command[9]="color 07";      //默认颜色  command[6]='0'+backColor;       //将backColor变量改为字符型 command[7]='0'+textColor;       //将textColor变量改为字符型 system(command);                //调用系统函数
}int userpassword()
{float x,y;for(x=1.3;x>=-1.1;x-=0.1){ for(y=-2;y<=1.4;y+=0.053){if(pow(x*x+y*y-1,3)-x*x*x*y*y<=0){printf("*");Sleep(2);}else{printf(" ");}}printf("\n");}printf("\t\t\t 欢迎进入学生体侧管理系统\n");char  username[20];char  password[20];char  realpassword[3][20];char  realusername[3][20];int cnt,i=0,flag=0;int error=0;/*打开文件*/FILE *fp=fopen("user.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s",realusername[i],realpassword[i]);i++;} cnt=i;printf("\t\t\t 请输入登录账号:");scanf ("%s",username);fflush(stdin);printf("\t\t\t 请输入登录密码:");scanf ("%s",password);fflush(stdin);while(1){for (i=0;i<cnt;i++)if (strcmp(password,realpassword[i])==0&&strcmp(username,realusername[i])==0){printf("\t\t\t 登录成功"); error=0;fclose(fp);return i;}printf("\t\t\t 账号或密码错误,请重新输入\n"); error++;printf("\t\t\t 请输入账号:"); scanf("%s",username);fflush(stdin);printf("\t\t\t 请输入密码:");scanf("%s",password);fflush(stdin);  if (error==3)  {printf("\t\t\t\t多次错误输入,无法打开");fclose(fp);exit(1);}}
}void mainmenu()                                    //主菜单视图
{system("cls");printf("                        --------------学生体测成绩判定系统功能菜单------------\n");printf("                        |      \t\t0. 退出系统                          |\n");printf("                        |      \t\t1. 学生体侧成绩录入                  |\n");printf("                        |      \t\t2. 学生体侧成绩排序                  |\n");printf("                        |      \t\t3. 学生体侧成绩统计                  |\n");printf("                        |      \t\t4. 学生体侧成绩查询                  |\n");printf("                        |      \t\t5. 学生体侧成绩修改                  |\n");printf("                        |      \t\t6. 学生体侧成绩删除                  |\n");printf("                        |      \t\t7. 切换账号                          |\n");printf("                        ------------------------------------------------------\n");
}void keydown(struct Node *list)                   //按键交互
{int choose;    //choose为功能选择 printf("\n请输入您需要的功能(0~~7): ");scanf("%d", &choose);choose=choiceinput(choose,0,7);switch (choose) {case 0:printf("退出系统确认提示\n"); int ret;ret=MessageBox(NULL, TEXT("请问是否退出系统?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==1) {printf("系统已关闭,感谢您的使用!");exit(0);}else {mainmenu();keydown(list); }break;case 1:printf("\t\t 欢迎使用[成绩录入]功能\n");input(list);  break;case 2:printf("\t\t 欢迎使用[成绩排序]功能\n");range(list);break;case 3:printf("\t\t 欢迎使用[成绩统计]功能\n");printlist(list);break;case 4:printf("\t\t  欢迎使用[成绩查询]功能\n");search(list); break;case 5:printf("\t\t 欢迎使用[成绩修改]功能\n");alter(list); break;case 6:printf("\t\t 欢迎使用[成绩删除]功能\n");deleted(list); break;case 7:printf("\t\t 欢迎使用[切换账号]功能\n");changeuser(list);free(list);struct Node *list = createlist(); switch(IDofusers){case 1: filescanf1(list); break;                   //将文件中的数据初始化进链表中case 2: filescanf2(list); break;case 3: filescanf3(list); break;}mainmenu();keydown(list);}
}//搭建一个链表的基本框架
struct Node* createlist()
{struct Node* headnode=(struct Node*)malloc(sizeof(struct Node)); headnode->next = NULL;return headnode;
}//创建结点
struct Node* createnode(struct student stu)
{struct Node* newnode=(struct Node*)malloc(sizeof(struct Node));newnode->stu = stu;/*将结构体的数据赋值给newnode里的结构体存起来*/newnode->next = NULL;return newnode;
}//插入
void insertnodebyhead(struct Node* headnode,struct student stu)
{struct Node* newnode=createnode(stu);newnode->next=headnode->next;headnode->next=newnode ;}/*功能一:录入成绩主函数*/
void input(struct Node *list)
{while (1){int ten; printf("\n请输入学生的学号:\n");scanf("%s",stu.num);judgestunum(list);             //判断学号长度与学号是否会出现重复 printf("请输入学生的姓名:\n");scanf("%s",stu.name);printf("请输入学生的性别(man或woman):\n");scanf("%s",stu.sex);fflush(stdin);printf("请输入学生的体重(单位:kg):\n");scanf("%f",&stu.weight);printf("请输入学生的身高(单位:米):\n");scanf("%f",&stu.height);printf("请输入学生的肺活量:\n");scanf("%d",&stu.vcp);while (1){if (sexjudge(stu.sex)==1)                    //判断性别 {printf("请输入学生的引体向上的个数:\n");scanf("%d",&stu.count);break; }else if (sexjudge(stu.sex)==2){printf("请输入学生的仰卧起坐的个数:\n");scanf("%d",&stu.count);break; }else {printf("性别输入错误,请重新输入该学生的性别(man或woman):");scanf("%s",stu.sex);fflush(stdin);}} stu=inputscore(stu);                                   //将数据转换为成绩并存储起来 insertnodebyhead(list,stu);  switch(IDofusers) {case 1: fileprint1(list); break;                   //将链表中的数据读进链表中case 2: fileprint2(list); break;case 3: fileprint3(list); break;}//把文件中的数据读到文件中 int ret=MessageBox(NULL, TEXT("请问是否继续录入?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2)                                           //输入“否”键将退出循环 {break;} }printf("录入成功,2秒后将退出");sleep(2); mainmenu();keydown(list);
} //判断输入的学号输入的正确性
void judgestunum(struct Node* list){struct Node *pr=list->next;int length;int ret;while (1){ret=1;pr=list->next;length=strlen(stu.num);if (length!=9){printf("输入长度错误,请重新输入(学号为9位):");scanf("%s",stu.num);continue;}while (pr){if (strcmp(stu.num,pr->stu.num)==0){printf("该学号已经存在,请重新输入:"); ret=0;scanf("%s",stu.num);break;}pr=pr->next;    }if (ret)  break;}free(pr);
} //将数据转换为成绩
struct student inputscore(struct student info) {//体重指数分数计算 info.BMI=info.weight/pow(info.height,2);if (info.BMI>=17.9&&info.BMI<=23.9){info.score1=100;}else if(info.BMI<17.9||(info.BMI>=24.0&&info.BMI<=27.9)){info.score1=80;}else info.score1=60;//肺活量分数计算if (sexjudge(info.sex)==1)       //性别判定为男{if (info.vcp>=4800) info.score2=100;else if (info.vcp<4800&&info.vcp>=4181)  info.score2=80;else if (info.vcp>=3101&&info.vcp<=4180) info.score2=60;else info.score2=30;} else if (sexjudge(info.sex)==2)  //性别判定为女 {if (info.vcp>=3400) info.score2=100;else if (info.vcp<3400&&info.vcp>3000)  info.score2=80;else if (info.vcp>=2051&&info.vcp<=3000) info.score2=60;else info.score2=30;} //引体向上和 仰卧起分数判断if (sexjudge(info.sex)==2)      //性别判定为女 {if (info.count>=56) info.score3=100;else if (info.count<56&&info.count>=53)  info.score3=80;else if (info.count>=25&&info.count<=52) info.score3=60;else info.score3=30;} else if (sexjudge(info.sex)==1)  //性别判定为男 {if (info.count>=19) info.score3=100;else if (info.count<19&&info.count>=16)  info.score3=80;else if (info.count>=10&&info.count<=15) info.score3=60;else info.score3=30;} info.scoreAll = (float)info.score1*0.25+(float)info.score2*0.35+(float)info.score3*0.4;//等级判定if (info.scoreAll>=95)  strcpy(info.level,no1);else if (info.scoreAll>=80&&info.scoreAll<=94)  strcpy(info.level,no2);else if (info.scoreAll>=60&&info.scoreAll<=79)  strcpy(info.level,no3);else strcpy(info.level,no4);return info; }/*功能二:排序主函数*/
void range(struct Node *headnode)
{printf("\n请问您想选择哪种排序方式(学号排序输入1,姓名排序输入2,分数排序输入3):");int n;scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,3);switch(n){case 1:rangebynum(headnode);break;case 2:rangebyname(headnode);break;case 3:rangebyscore(headnode);break; } print();struct Node *p=headnode->next;while (p){printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.BMI,p->stu.vcp,p->stu.count,p->stu.scoreAll,p->stu.level);p=p->next;}printline();                           //打印下划线,构成图表 printf ("\n输入回车键返回主菜单:");getchar();mainmenu();keydown(headnode);
} void rangebyname(struct Node* headnode)  //姓名排序
{int i;struct student msg;struct Node *p=headnode->next;struct Node *q=headnode;for (i=1;i<=20;i++){while(p->next){if (strcmp(p->stu.name,p->next->stu.name)<0){msg=p->stu;p->stu = p->next->stu;p->next->stu=msg;}p=p->next;}p=q->next;}
} void rangebynum(struct Node* headnode)  //学号排序
{int i;struct student msg;struct Node *p=headnode->next;struct Node *q=headnode;for (i=1;i<=20;i++){while(p->next){if (strcmp(p->stu.num,p->next->stu.num)>0){msg=p->stu;p->stu = p->next->stu;p->next->stu=msg;}p=p->next;}p=q->next;}
} void rangebyscore(struct Node* headnode)   //分数排序
{int i;struct student msg;struct Node *p=headnode->next;struct Node *q=headnode;for (i=1;i<=20;i++){while(p->next){if (p->stu.scoreAll >  p->next->stu.scoreAll){msg=p->stu;p->stu = p->next->stu;p->next->stu=msg;}p=p->next;}p=q->next;}
} /*功能三:统计功能主函数*/
void printlist(struct Node* headnode) //遍历
{struct Node *p=headnode->next;int allnumber=0;float averagescore1=0,averagescore2=0,averagescore3=0;float averagescoreAll=0;printf("这是已录入的学生体侧成绩\n");print(); while (p){//      printf("%-15s%-8s%-5s%-5.1f%-7.2f%-8d%-3d\n",p->stu.num,p->stu.name,p->stu.sex,
//              p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count);
//上面是数据,下面是成绩 printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.BMI,p->stu.vcp,p->stu.count,p->stu.scoreAll,p->stu.level);averagescore1+=p->stu.score1;averagescore2+=p->stu.score2;averagescore3+=p->stu.score3;averagescoreAll+=p->stu.scoreAll;p=p->next;allnumber++;}printline();printf("\n");averagescore1/=allnumber;averagescore2/=allnumber;averagescore3/=allnumber;averagescoreAll/=allnumber;printf("现在已经录入了%d个学生的成绩\n",allnumber);printf("\n分数数据概况:\n"); printf("体重指数平均分为%.1f,肺活量平均分为%.1f,引体向上和仰卧起坐的平均分为%.1f,总分的平均分为%.1f\n",averagescore1,averagescore2,averagescore3,averagescoreAll);int staticvcps[3]={0,0,0};  //定义了数组来放vcp的最大值,最小值与平均值      staticvcp(headnode,allnumber,staticvcps);printf("\n本班学生肺活量最高值是%d,最低值是%d,平均值是%d\n",staticvcps[0],staticvcps[1],staticvcps[2]);int staticcounts[6]={0,0,0,0,0,0};  staticcount(headnode,allnumber,staticcounts);printf("本班学生引体向上最高值是%d,最低值是%d,平均值是%d\n",staticcounts[0],staticcounts[1],staticcounts[2]);float staticBMIs[3]={0,0,0};staticBMI(headnode,allnumber,staticBMIs);printf("本班学生体重指数最高值是%.1f,最低值是%.1f,平均值是%.1f\n",staticBMIs[0],staticBMIs[1],staticBMIs[2]);int staticscores[8]={0,0,0,0,0,0,0,0};scorelevel(headnode,allnumber,staticscores);printf("\n本班男生评价为excellent的有%d人,评价为good有%d人,评价为pass的有%d人,评价为fail的有%d人\n" ,staticscores[0],staticscores[1],staticscores[2],staticscores[3]);printf("本班女生评价为excellent的有%d人,评价为good有%d人,评价为pass的有%d人,评价为fail的有%d人\n" ,staticscores[4],staticscores[5],staticscores[6],staticscores[7]);    getchar();printf ("\n统计结束,输入回车键返回主菜单:");getchar();mainmenu();keydown(headnode);
}/*各项数据统计细则*/
void staticvcp (struct Node* headnode,int n,int *vcps)    //vcp统计
{struct Node *p=headnode->next;vcps[1]=p->stu.vcp; while (p){if (vcps[0] < p->stu.vcp)  vcps[0]=p->stu.vcp;  //0存最高值 if (vcps[1] > p->stu.vcp)  vcps[1]=p->stu.vcp;  //1存最小值 vcps[2] += p->stu.vcp;                          //2存平均值 p=p->next;}vcps[2]/=n;}void staticcount (struct Node* headnode,int n,int *counts)   //仰卧起坐,引体向上数据统计
{struct Node *p=headnode->next;int cnt=0,cntt=0;while (p){if (sexjudge(p->stu.sex)==1){if (cnt==0)   counts[1]=p->stu.count;                      //给count赋初值,防止最小值显示为1 if (counts[0] < p->stu.count)  counts[0]=p->stu.count;if (counts[1] > p->stu.count)  counts[1]=p->stu.count;counts[2]+=p->stu.vcp;cnt++;}else if (sexjudge(p->stu.sex)==2){                           if (cntt==0)  counts[4]=p->stu.count;                      //给count赋初值,防止最小值显示为1if (counts[3] < p->stu.count)  counts[3]=p->stu.count;if (counts[4] > p->stu.count)  counts[4]=p->stu.count;counts[5]+=p->stu.vcp;cntt++;}p=p->next;}counts[2]/=n;
}void staticBMI(struct Node* headnode,int n,float *BMIs)   //BMI数据统计
{struct Node *p=headnode->next;BMIs[1]=p->stu.BMI; while (p){if (BMIs[0] < p->stu.BMI)  BMIs[0]=p->stu.BMI;   //0存最高值 if (BMIs[1] > p->stu.BMI)  BMIs[1]=p->stu.BMI;   //1存最小值 BMIs[2] += p->stu.BMI;                           //2存平均值 p=p->next;}BMIs[2]/=n;
}void scorelevel(struct Node* headnode,int n,int *scores) //score有8个值,前4个男生,后四个女生
{struct Node *p=headnode->next;while (p){if (sexjudge(p->stu.sex)==1){if (strcmp(p->stu.level,no1)==0) scores[0]++;else if (strcmp(p->stu.level,no2)==0) scores[1]++;else if (strcmp(p->stu.level,no3)==0) scores[2]++;else if (strcmp(p->stu.level,no4)==0) scores[3]++;}else if (sexjudge(p->stu.sex)==2){if (strcmp(p->stu.level,no1)==0) scores[4]++;else if (strcmp(p->stu.level,no2)==0) scores[5]++;else if (strcmp(p->stu.level,no3)==0) scores[6]++;else if (strcmp(p->stu.level,no4)==0) scores[7]++;} p=p->next;}} /*功能四:查询某人成绩*/
void search (struct Node* headnode)
{while (1){printf("\n请问您是使用姓名查询,学号查询还是分数查询(学号查询输入1,姓名查询输入2,分数查询输入3):");int n;char searchnum[20];char searchname[10]; int searchscore;scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,3); switch(n){case 1:printf("\n请输入您要查询学生的学号:");scanf("%s",searchnum);searchbynum(headnode,searchnum);break;case 2:printf("\n请输入您要查询学生的姓名:");scanf("%s",searchname);searchbyname(headnode,searchname);break;case 3:printf("\n请输入您要查询学生的分数:");scanf("%d",&searchscore);searchbyscore(headnode,searchscore);break; }getchar();int ret;ret=MessageBox(NULL, TEXT("请问是否需要继续查询?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2) break; }printf ("\n查询结束,输入回车键返回主菜单:");getchar(); mainmenu();keydown(headnode);
} void searchbynum(struct Node* headnode,char searchnum[])  //根据学号找人的函数
{printf("\n");char a; struct Node* searchnode = headnode->next;if (searchnode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(searchnode->stu.num,searchnum)!=0){searchnode=searchnode->next;if (searchnode==NULL){printf("没有找到该学生的相关消息\n");break;}}  }if (searchnode!=NULL){print(); printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",searchnode->stu.num,searchnode->stu.name,searchnode->stu.sex,searchnode->stu.BMI,searchnode->stu.vcp,searchnode->stu.count,searchnode->stu.scoreAll,searchnode->stu.level);printline();getchar();printf("\n若对该学生分数有疑惑,输入y可查看具体分数细则,若无疑惑输入任意字符:");scanf("%c",&a); if (a=='y'){if (sexjudge(searchnode->stu.sex)==1){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 引体向上分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,引体向上个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }else if (sexjudge(searchnode->stu.sex)==2){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 仰卧起坐分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,仰卧起坐个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }printf("所以%d * 0.25 + %d * 0.35 + %d * 0.4 = %d",searchnode->stu.score1,searchnode->stu.score2,searchnode->stu.score3,searchnode->stu.scoreAll);}}} void searchbyname(struct Node* headnode,char searchname[])   //根据姓名找人的函数
{printf("\n");char a;struct Node* searchnode = headnode->next;if (searchnode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(searchnode->stu.name,searchname)!=0){searchnode=searchnode->next;if (searchnode==NULL){printf("没有找到该学生的相关消息\n");break;}} }if (searchnode!=NULL){print() ;printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",searchnode->stu.num,searchnode->stu.name,searchnode->stu.sex,searchnode->stu.BMI,searchnode->stu.vcp,searchnode->stu.count,searchnode->stu.scoreAll,searchnode->stu.level);printline();getchar();printf("\n若对该学生分数有疑惑,输入y可查看具体分数细则,若无疑惑输入任意字符:");scanf("%c",&a); if (a=='y'){if (sexjudge(searchnode->stu.sex)==1){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 引体向上分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,引体向上个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }else if (sexjudge(searchnode->stu.sex)==2){printf("分数计算公式为: 体重指数分数×25%% + 肺活量分数×35%%+ 仰卧起坐分数×40%%\n");printf("该生体重指数为%.1f,对应%d分,肺活量为%d,对应%d分,仰卧起坐个数为%d个,对应%d分\n",searchnode->stu.BMI,searchnode->stu.score1,searchnode->stu.vcp,searchnode->stu.score2,searchnode->stu.count,searchnode->stu.score3); }printf("所以%d * 0.25 + %d * 0.35 + %d * 0.4 = %d",searchnode->stu.score1,searchnode->stu.score2,searchnode->stu.score3,searchnode->stu.scoreAll);}}
}void searchbyscore(struct Node* headnode,int searchscore)   //根据分数找人的函数
{printf("\n");struct Node* searchnode = headnode->next;int cnt=0;if (searchnode==NULL){printf("您还未录入任何人的信息\n"); }else{while (searchnode){if (searchnode->stu.scoreAll==searchscore){cnt++;if (cnt==1)  print() ; printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",searchnode->stu.num,searchnode->stu.name,searchnode->stu.sex,searchnode->stu.BMI,searchnode->stu.vcp,searchnode->stu.count,searchnode->stu.scoreAll,searchnode->stu.level);}searchnode=searchnode->next;}  }if (cnt==0){printf("本班无学生分数为%d\n",searchscore);}else printline();
}/*功能五:修改某人成绩*/
void alter (struct Node* headnode)  //根据学号找人的函数
{while(1){printf("请输入所修改信息的学生的姓名或学号(学号输入1,姓名输入2):");int n;char alternum[20];char altername[10]; scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,2);switch(n){case 1:printf("\n请输入您要修改的学生的学号:");scanf("%s",alternum);alterbynum(headnode,alternum);break;case 2:printf("\n请输入您要修改的学生的姓名:");scanf("%s",altername);alterbyname(headnode,altername);break;} switch(IDofusers) {case 1: fileprint1(headnode); break;                   //将链表中的数据读进链表中case 2: fileprint2(headnode); break;case 3: fileprint3(headnode); break;}int ret;ret=MessageBox(NULL, TEXT("请问是否继续使用修改功能?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2) break;}printf ("\n修改结束,输入回车键返回主菜单:");getchar();mainmenu();keydown(headnode);
} void alterbynum(struct Node* headnode,char alternum[])  //根据学号找人的函数
{struct Node* alternode = headnode->next;if (alternode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(alternode->stu.num,alternum)!=0){alternode=alternode->next;if (alternode==NULL){printf("没有找到该学生的相关消息\n");break;}}    }if (alternode!=NULL){printf("这是修改前学生的成绩:\n"); print() ; printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",alternode->stu.num,alternode->stu.name,alternode->stu.sex,alternode->stu.BMI,alternode->stu.vcp,alternode->stu.count,alternode->stu.scoreAll,alternode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认修改该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1)  alterprocess(alternode);else if (n==2) printf("\n结束修改该学生信息的操作");}
} void alterbyname(struct Node* headnode,char altername[])   //根据姓名找人的函数
{struct Node* alternode = headnode->next;if (alternode==NULL){printf("您还未录入任何人的信息\n"); }else{while (strcmp(alternode->stu.name,altername)!=0){alternode=alternode->next;if (alternode==NULL){printf("没有找到该学生的相关消息\n");break;}}  }if (alternode!=NULL){printf("这是修改前学生的信息:\n"); print() ;printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",alternode->stu.num,alternode->stu.name,alternode->stu.sex,alternode->stu.BMI,alternode->stu.vcp,alternode->stu.count,alternode->stu.scoreAll,alternode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认修改该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1)  alterprocess(alternode);else if (n==2) printf("\n结束修改该学生信息的操作");}
}void alterprocess(struct Node* alternode)
{printf("\n请问您要修改哪项数据(体重输入1,身高输入2,肺活量输入3,引体向上输入4):");int n;scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,4);printf("\n您将此数据修改为:");int afteralter1;float afteralter2;switch (n){case 1:scanf("%f",&afteralter2);fflush(stdin);alternode->stu.weight=afteralter2;break;case 2:scanf("%f",&afteralter2);fflush(stdin);alternode->stu.height=afteralter2;break;case 3:scanf("%d",&afteralter1);fflush(stdin);alternode->stu.vcp=afteralter1;break;case 4:scanf("%d",&afteralter1);fflush(stdin); alternode->stu.count=afteralter1;break;}printf("\n这是修改后学生的信息:\n"); alternode->stu=inputscore(alternode->stu); print() ;printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",alternode->stu.num,alternode->stu.name,alternode->stu.sex,alternode->stu.BMI,alternode->stu.vcp,alternode->stu.count,alternode->stu.scoreAll,alternode->stu.level);printline();
} /*功能六:删除功能的主函数*/
void deleted(struct Node* headnode)
{while(1){printf("\n请问您是选择输入姓名删除还是输入学号删除(选择学号输入1,选择姓名输入2):") ;int n;char deletenum[20];char deletename[10]; scanf("%d",&n);fflush(stdin);n=choiceinput(n,1,3);switch(n){case 1:printf("请输入您所要删除的学生的学号:");scanf("%s",deletenum);deletebynum(headnode,deletenum);break;case 2:printf("请输入您所要删除学生的姓名:");scanf("%s",deletename);deletebyname(headnode,deletename);break;} switch(IDofusers) {case 1: fileprint1(headnode); break;                   //将链表中的数据读进链表中case 2: fileprint2(headnode); break;case 3: fileprint3(headnode); break;}Sleep(1);int ret;ret=MessageBox(NULL, TEXT("请问是否继续使用删除功能?"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (ret==2) break;}mainmenu();keydown(headnode);
}void  deletebynum(struct Node* headnode,char posnum[])  //根据学号删除
{int n;int cnt=0; struct Node* posnode = headnode->next;struct Node* posnodeFront=headnode;if (posnode==NULL){printf("无法删除,链表为空\n"); }else{while (strcmp(posnode->stu.num,posnum)!=0){posnodeFront=posnode;posnode=posnode->next;if (posnode==NULL){printf("没有找到该学生,请确定输入是否正确\n");cnt=1;break;}}  }if (cnt==0){printf("这是要删除学生的数据\n");print();printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",posnode->stu.num,posnode->stu.name,posnode->stu.sex,posnode->stu.BMI,posnode->stu.vcp,posnode->stu.count,posnode->stu.scoreAll,posnode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认删除该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1){posnodeFront->next=posnode->next;free(posnode);printf("删除成功\n");}else {printf("已经放弃删除\n");} }
}void  deletebyname(struct Node* headnode,char posname[])  //根据姓名删除
{int cnt=0;struct Node* posnode = headnode->next;struct Node* posnodeFront=headnode;if (posnode==NULL){printf("无法删除,信息表为空\n"); }else{while (strcmp(posnode->stu.name,posname)!=0){posnodeFront=posnode;posnode=posnode->next;if (posnode==NULL){printf("没有找到该学生,请确定输入是否正确\n");cnt=1;break;}}  }if (cnt==0){printf("这是要删除学生的数据\n");print();printf("|%-15s%-8s%-6s  %-9.1f %-19d %-11d %-10d %-9s|\n",posnode->stu.num,posnode->stu.name,posnode->stu.sex,posnode->stu.BMI,posnode->stu.vcp,posnode->stu.count,posnode->stu.scoreAll,posnode->stu.level);printline();int n=MessageBox(NULL, TEXT("请问您是否确认删除该学生信息"), TEXT("确认提示"), MB_OKCANCEL | MB_ICONQUESTION);if (n==1){posnodeFront->next=posnode->next;free(posnode);printf("删除成功\n");}else {printf("已经放弃删除\n");} }
}/*功能七:切换账号*/
void changeuser(struct Node* headnode)
{char  username[20];char  password[20];char  realpassword[3][20];char  realusername[3][20];int cnt,i=0,error=0,flag=0;/*打开文件*/FILE *fp=fopen("user.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s",realusername[i],realpassword[i]);i++;} cnt=i;printf("\t\t\t 请输入账号:");scanf ("%s",username);fflush(stdin);printf("\t\t\t 请输入密码:");scanf ("%s",password);fflush(stdin);while(1){for (i=0;i<cnt;i++)if (strcmp(password,realpassword[i])==0&&strcmp(username,realusername[i])==0){printf("\t\t\t 切换成功");IDofusers = i+1;flag=1;fclose(fp);break;}if (flag==0){printf("\t\t\t 账号或密码错误,请重新输入\n"); error++;printf("\t\t\t 请输入账号:"); scanf("%s",username);fflush(stdin);printf("\t\t\t 请输入密码:");scanf("%s",password);fflush(stdin);    if (error==3)  {printf("\t\t\t\t多次错误输入,切换失败");fclose(fp);}}else {break;}}
}/*从文件中读内容*/
void filescanf1(struct Node* headnode)
{FILE *fp=fopen("test1.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s %s %f %f %d %d",stu.num,stu.name,stu.sex,&stu.weight,&stu.height, &stu.vcp, &stu.count);stu=inputscore(stu);insertnodebyhead(headnode,stu);} fclose(fp);
} void filescanf2(struct Node* headnode)
{FILE *fp=fopen("test2.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s %s %f %f %d %d",stu.num,stu.name,stu.sex,&stu.weight,&stu.height, &stu.vcp, &stu.count);stu=inputscore(stu);insertnodebyhead(headnode,stu);} fclose(fp);
}void filescanf3(struct Node* headnode)
{FILE *fp=fopen("test3.txt","r");if(fp == NULL){printf("无法打开文件\n");}while(!feof(fp)){fscanf(fp,"%s %s %s %f %f %d %d",stu.num,stu.name,stu.sex,&stu.weight,&stu.height, &stu.vcp, &stu.count);stu=inputscore(stu);insertnodebyhead(headnode,stu);} fclose(fp);
}  /*读内容给文件*/
void fileprint1(struct Node* headnode)
{FILE *fp=fopen("test1.txt","w");if(fp == NULL){printf("无法打开文件\n");}struct Node* p=headnode->next;while (p) {fprintf(fp,"\n");fprintf(fp,"%s %s %s %.1f %.2f %d %d",p->stu.num,p->stu.name,p->stu.sex,p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count) ;p=p->next;}fclose(fp);
} void fileprint2(struct Node* headnode)
{FILE *fp=fopen("test2.txt","w");if(fp == NULL){printf("无法打开文件\n");}struct Node* p=headnode->next;while (p) {fprintf(fp,"\n");fprintf(fp,"%s %s %s %.1f %.2f %d %d",p->stu.num,p->stu.name,p->stu.sex,p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count) ;p=p->next;}fclose(fp);
} void fileprint3(struct Node* headnode)
{FILE *fp=fopen("test3.txt","w");if(fp == NULL){printf("无法打开文件\n");}struct Node* p=headnode->next;while (p) {fprintf(fp,"\n");fprintf(fp,"%s %s %s %.1f %.2f %d %d",p->stu.num,p->stu.name,p->stu.sex,p->stu.weight,p->stu.height,p->stu.vcp,p->stu.count) ;p=p->next;}fclose(fp);
} void print(){printf("______________________________________________________________________________________________\n");printf("|  学号    |   姓名  | 性别 | 体重指数 | 肺活量 | 引体向上/仰卧起坐个数 | 总分数 |  成绩等级  |\n") ;
}
void printline(){printf("|_____________________________________________________________________________________________|\n");
}//判断输入合法性
int choiceinput(int choose,int m,int n){while (choose > n || choose < m) {printf("您输入了一个无效的选择,请重新输入: ");scanf("%d", &choose);}return choose;
}//判断性别函数
int sexjudge(char sex[]){int a;char man[4]="man";char woman[6]="woman";if (strcmp(sex,man)==0){a=1; }else if (strcmp(sex,woman)==0){a=2;            }else a=3;return a;
}

7.文件中的内容

user文件夹
1274669808 1234
1274669807 12345
1274669806 123456

text1的文件(系统中对学号长度及其重复性是有规定的)
csu201401 jzn man 64.5 1.81 3400 14
csu201402 ql man 75.5 1.70 2000 2
csu201403 zwz man 74.6 1.85 4450 32
csu201405 jzn man 64.5 1.81 3400 12
csu201414 wd man 64.0 1.74 3600 12
csu201422 ldx woman 49.0 1.63 3000 23
csu201423 lty man 60.7 1.76 3500 1
csu201424 jwq man 78.0 1.77 2346 12
csu201425 jst woman 60.0 1.68 8000 50
csu201426 jwq man 90.0 1.74 2300 50
csu201428 lxl man 64.0 1.88 6000 1

text2文件
csu201501 ccb man 55.0 1.70 3689 18
csu201502 cqy woman 49.5 1.59 2300 40
csu201503 yrf woman 43.4 1.62 2100 23
csu201504 cky man 78.2 1.79 3900 2
csu201505 cr man 58.8 1.72 4400 45

text3文件
csu201308 zzh man 100.0 1.80 3000 1
csu201327 zyk man 55.0 1.74 4750 19
csu201322 lb man 72.0 1.88 2900 10
csu201309 zyn woman 47.9 1.74 5000 31
csu201305 cx man 60.7 1.76 3500 1
csu201304 wml woman 60.8 1.69 2987 20
csu201303 nb woman 50.0 1.77 3450 35
csu201302 zbw man 54.9 1.74 4789 39
csu201301 zzh man 75.9 1.75 3000 5

8.最终效果图部分展示


学生体侧成绩管理系统(文件+链表)相关推荐

  1. 烟台大学体侧成绩估算(根据2012年标准)男生版

    #include<iostream> #include<iomanip> #include<cmath> using namespace std; int main ...

  2. Java+MySQL学生选课与成绩管理系统(数据库版)

    一.项目要求 学生选课与成绩管理系统(数据库版) 1.配置MySQL数据库 2.利用java+MySQL实现系统各个功能 3.功能包括: (1)系统交互界面,如下图所示 (2)学生信息的增删改查.学生 ...

  3. 西南交通大学高级语言程序设计(SCAI000812)第2次实验报告-学生成绩管理系统(链表版)

    背景描述: 因为苦于网上到处都找不到答案,仅有的链表版还要收费,我就自己写了一个低配版链表,将就着用,想的是帮助明年以及后年的学弟学妹们. 题目描述: 实验目的: 掌握程序设计的基本算法和简单数据结构 ...

  4. c语言实现学生二科成绩的单链表,c++链表实现学生成绩管理系统(简易版)

    #include using namespace std; typedef struct student{ int id;//学号 string sex; string name; int cpp;/ ...

  5. 成绩管理系统(链表)c语言

    根据学校教的东西整的(本人大一,别杠,杠就是你对,我才刚接触这个) 结构体数组的方式存在存在有限制的情况.目前我还不会如何将结构体数组进行动态扩充. 每次存到记事本里的样子大概就这样.能够通过输入的语 ...

  6. springboot+vue+nodejs学生平时综合成绩管理系统java_o8mkp

    学生成绩管理系统是学校信息化管理的辅助系统.它和学校的管理模式密切相关,并为学校的最终目标服务[5].因而学校管理工作规范化是建设校园管理系统的基础.学生信息管理系统是校园管理系统的重要组成.它是针对 ...

  7. php学生作业管理,学生课程作业成绩管理系统

     学生课程作业管理系统,由本站设计师开发完成.该软件有管理员.教师.学生三种用户角色,有课程管理.作业管理.管理员设置.教师管理.学生管理.作业批改等模块,程序功能齐全.我们的设计师从事学生毕业设 ...

  8. ssm+JSP计算机毕业设计学生选课与成绩管理系统d269s【源码、程序、数据库、部署】

    项目运行 项目含有源码(见文末).文档.程序.数据库.配套开发软件.软件安装教程 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ E ...

  9. ssm+jsp计算机毕业设计学生选课与成绩管理系统d269s(程序+lw+源码+远程部署)

    项目运行 项目含有源码(见文末).文档.程序.数据库.配套开发软件.软件安装教程 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ E ...

最新文章

  1. 如何使用多个参数调用Angular.js过滤器?
  2. 代码审计之Catfish CMS v4.5.7后台作者权限越权两枚+存储型XSS一枚
  3. python 冒泡排序_Python中的冒泡排序
  4. 解析php混淆加密解密的手段,如 phpjm,phpdp神盾,php威盾
  5. 随想录(中间件接口的定义方法)
  6. [转]2020年2月份Github上最热门的开源项目,速来围观
  7. java 小程序--杨辉三角
  8. express在本地起一个简单服务器可能会用到的(本文用的uniapp做例子)
  9. ThinkPHP5零食商城系统(前后台)
  10. 14届数独-真题标准数独-Day 3-20220118
  11. C语言删除注册表某个键值,怎么批量快速删除注册表中指定的某个键值
  12. 一小时学会Python3爬虫基础(七)高级数据的全部操作:列表
  13. 连接服务器显示句柄无效,紧急求助!!1  打印机不能打印 提示:句柄无效...
  14. 12306刷票工具(简单易学)
  15. Android那些事!
  16. spring boot + netty实现匿名聊天室 web版
  17. Win10打开“此电脑”读绿条,显示“正在处理”
  18. 【PMP】核对单和核查表的区别
  19. win10 电脑找不到WIFI,手机却能连上,问题解决
  20. 5xx 系列内部服务器错误

热门文章

  1. JavaScript倒计时代码
  2. NC语义模型和报表设计及报表的发布
  3. matlab r53,【GE逻辑测试面试题】面试问题:4. MIZ7… - 看准网
  4. nfc是什么?nfc功能是什么?
  5. MySQL 五种整型数据类型的范围与区别 tinyint smallint mediumint int bigint
  6. 微信小程序(四)小程序生命周期
  7. 景观风水十大原则 (转载)
  8. 3、Explan执行计划
  9. [NOIP2017]逛公园
  10. 腾讯定位服务使用教程Android版