From acd278d32f142801f78b18dcda66fdbb051e1e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E9=B9=8F=E4=BF=8A=E2=80=9D?= <1106548749@qq.com> Date: Thu, 10 Jan 2019 10:45:50 +0800 Subject: [PATCH] first commit --- c1.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 c1.cpp diff --git a/c1.cpp b/c1.cpp new file mode 100644 index 0000000..1f11e11 --- /dev/null +++ b/c1.cpp @@ -0,0 +1,64 @@ +#include"头文件.cpp" +int fun() //目录函数 +{ + int n; + system("cls"); + printf("\n\n\t\t\t\t 成绩记录簿"); + printf("\n\n\t\t\t"); + for(int i=0;i<36;i++) + printf("*"); + printf("\n"); + printf("\t\t\t *************菜单***************\n"); + printf("\t\t\t*|1、创建学生的信息! \t|*\n"); + printf("\t\t\t*|2、输出所有学生的信息! \t|*\n"); + printf("\t\t\t*|3、修改成绩! \t|*\n"); + printf("\t\t\t*|4、查询! \t|*\n"); + printf("\t\t\t*|5、显示成绩分段的学生信息! \t|*\n"); + printf("\t\t\t*|6、学生成绩排名! \t|*\n"); + printf("\t\t\t*|7、退出成绩记录簿! \t|*\n"); + printf("\t\t\t *****设计者:吕永太 朱鹏俊****\n"); + printf("\t\t\t"); + for(int i=0;i<36;i++) + printf("*"); + printf("\n\n"); + printf("\n\t\t\t 请输入选项:"); + scanf("%d",&n); + return n; +} +void input() //成绩输入 +{ + Student s[50]; + system("cls"); + int i=0; + FILE *fp; + fp=fopen("a.txt","a+"); + printf("请以0作为输入学生学号信息的结束!\n"); + do + { + printf("输入学生的学号:"); + scanf("%lf",&s[i].no); + printf("输入学生的姓名:"); + scanf("%s",s[i].name); + printf("输入学生的C语言成绩:"); + scanf("%f",&s[i].cscore); + if(s[i].no!=0) + fprintf(fp,"%.0lf %-4s %.1f\n",s[i].no,s[i].name,s[i].cscore); + }while(s[i].no!=0); + fclose(fp); +} +void output() //成绩输出 +{ + if((fp=fopen("a.txt","r"))==NULL) + { + printf("Cannot open the file!\n"); + + } + printf("\t\t\t全部的学生信息:\n"); + int k=0; + while(fscanf(fp,"%lf%s%f",&s[k].no,s[k].name,&s[k].cscore)!=EOF) + { + printf("\t\t\t%.0lf\t%s\t%.1f\n",s[k].no,s[k].name,s[k].cscore); + k++; + } + fclose(fp); +}