From 236046441f755bf60fe3606f05d5d4f96c46a68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A1=93?= <2632716331@qq.com> Date: Thu, 10 Jan 2019 14:36:27 +0800 Subject: [PATCH] first commit --- student.cpp | 574 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 574 insertions(+) create mode 100644 student.cpp diff --git a/student.cpp b/student.cpp new file mode 100644 index 0000000..ef3de8b --- /dev/null +++ b/student.cpp @@ -0,0 +1,574 @@ +#include"stdio.h" +#include"windows.h" +#include"conio.h" +#include"stdlib.h" +#include"string.h" +int menu(); +int menu_select(); +void tj(); +void cx(); +int xg(); +void xs(); +void fd(); +void pm(); +float fm(); +int pass(); +int average(); +int wenjiandiaochu(); +int mima(); +int i,j,k,y; +FILE *fp; +struct stu +{ +int xh; +char name[30]; +float score; +};struct stu s[100]; +int main() +{ +system("color F4");//亮白,红 +system("pause"); +int e; +e=mima(); +if(e==1) +return 0; +printf("\n"); +printf("\t*-*-*-*-*-*-*-*-*-*-*-*-*-*\n"); +printf("\t* 好嗨哟! *\n"); +printf("\t* 恭喜你的人生到达了 *\n"); +printf("\t* 学生C语言成绩记录簿系统 *\n"); +printf("\t* *^_^* *\n"); +printf("\t* *^欢迎使用^* *\n"); +printf("\t*-*-*-*-*-*-*-*-*-*-*-*-*-*\n"); +printf("\n"); +menu(); +return 0; +} + +int menu()//菜单 +{ + + int n=0; + char c,a; + n=menu_select(); + +switch(n) + { +case 0: tj(); break;//添加 +case 1: xg(); break;// 修改 +case 2: xs(); break;//显示 +case 3: cx();break;//查询 +case 4: pm();break;//排序 +case 5: fm();break;//最高和最低分 +case 6: average();break;//平均分 +case 7: pass();break;//及格率 +case 8: fd();break;//学生成绩分段 +case 9: return 0;//结束 + } + if(0<=n&&n<=8) + { + printf("是否继续对学生成绩进行管理,是请输入Y,否请输入N\n"); + a=getchar(); + scanf("%c",&c); + + if(c=='y'||c=='Y') + { + system("cls"); + menu(); + } + +while(c!='y'&&c!='Y'&&c!='n'&&c!='N') + { + printf("你的输入怕是有毛病,现在请重新输入:\n"); + scanf("%c",&c); + getchar(); + if(c=='y'||c=='Y') + { + system("cls"); + menu(); + } + if(c=='n'||c=='N') + { + return 0; + } + } + + } +} + + int menu_select()//菜单选择 +{int a; +printf("\n"); +printf("\t*-*-*-*-*-*-*-*-*-*-*-*-*-*\n"); +printf("\t*-0. 添加学生信息 -*\n"); +printf("\t*-1. 修改学生信息 -*\n"); +printf("\t*-2. 显示学生信息 -*\n"); +printf("\t*-3. 查询学生信息 -*\n"); +printf("\t*-4. 学生信息排序 -*\n"); +printf("\t*-5. 最高和最低分 -*\n"); +printf("\t*-6. 平均分 -*\n"); +printf("\t*-7. 及格率 -*\n"); +printf("\t*-8. 学生成绩分段 -*\n"); +printf("\t*-9. 结束运行 -*\n"); +printf("\t*-*-*-*-*-*-*-*-*-*-*-*-*-*\n"); +printf("\n\t请输入功能选择对应的数据, 请选0~9:\n"); +scanf("%d",&a); +getchar();//接收回车符 + while(!(a>=0&&a<=9)) + { + printf("你的输入怕是有点问题哦,麻烦再输入一次"); + scanf("%d",&a); + getchar(); + } +return a; +} + +int xg() //修改 +{ +FILE *fp1; +char st[30]; +int num,k,x,id; +float nu; +system("cls"); +wenjiandiaochu(); +if((fp1=fopen("学生人数.txt","r"))==NULL) + { + printf("文件冇得办法打开"); + return 0; + } + fscanf(fp1,"%d",&k); + fclose(fp1); +printf("学号修改请按1,姓名修改请按2,莫要选错了:\n"); +scanf("%d",&x); +while(x!=1&&x!=2) + { + printf("你的输入怕是有毛病,现在请重新输入:\n"); + scanf("%d",&x); + } +if(x==1) +{ +printf("现在输入修改成绩人的学号:\n"); +scanf("%d",&num); +for(int i=0;i=60) + m++; */ + printf("\t\t\t第%d名:%d %-4s %.1f\n",i+1,s[i].xh,s[i].name,s[i].score); + } + printf("是否要将排序后的数据保存,是请按1,否请按0:\n"); + scanf("%d",&a); + c=getchar();//接收回车 +while(a!=1&&a!=0) + { + printf("你的输入怕是有毛病,现在请重新输入:\n"); + scanf("%d",&a); + } + if(a==1) + { + if((fp=fopen("student.txt","w+"))==NULL) + { + printf("文件冇得办法打开"); + exit(0); + } + for(int l=0;l=90) +printf("\t\t\t%d %s %.1f%ld\n",s[i].xh,s[i].name,s[i].score); +printf("\n\n"); +printf("\t\t\t 80到89分学生的信息!\n"); +printf("\t\t\t学号 姓名 成绩:\n"); +for(i=0;i=80) +printf("\t\t\t%d %s %.1f%ld\n",s[i].xh,s[i].name,s[i].score); +printf("\n\n"); +printf("\t\t\t 60到79分学生的信息!\n"); +printf("\t\t\t学号 姓名 成绩:\n"); +for(i=0;i=60&&s[i].score<80) +printf("\t\t\t%d %s %.1f%ld\n",s[i].xh,s[i].name,s[i].score); +printf("\n\n"); +printf("\t\t\t 60分以下学生的信息!\n"); +printf("\t\t\t学号 姓名 成绩:\n"); +for(i=0;imax) + max=s[i].score; + if(s[i].score=60) + p++; + } + c=p/k; + printf("当前学生C语言成绩的及格率为:%.2f\n",c); + return 0; + +} + +int mima()//密码设置 +{ + char m[10],c; + int i; + printf("\n\n\n\n\t\t\t\t请输入8位数字管理员密码:\n"); + for(i=0;i<8;i++) + { + m[i]=getch(); + printf("$"); + } + c=getchar();//接收回车符 + m[i]='\0';//用空格做结束标记,使后面的i+n作废 + printf("\n"); + if(strcmp(m,"14789632")==0) + return 0; + if(strcmp(m,"14789632")!=0) + { + printf("密码不对呀!你怕四记错了哦!响一哈再输入一次:\n"); + for(i=0;i<8;i++) + { + m[i]=getch(); + printf("$"); + } + c=getchar();//接收回车符 + m[i]='\0';//用空格做结束标记,使后面的i+n作废 + printf("\n"); + if(strcmp(m,"14789632")==0) + return 0; + else + { + printf("密码错误,系统退出\n"); + return 1; + } + return 0; + } + } + +