You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.9 KiB
85 lines
1.9 KiB
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
int i,j,k,y;
|
|
FILE *fp;
|
|
struct stu {
|
|
int num;
|
|
char name[30];
|
|
double cscore;
|
|
};
|
|
struct stu s[100];
|
|
|
|
int fun() { // 目录函数
|
|
int n;
|
|
system("cls");
|
|
printf("\n\n\t\t\t\t欢迎使用成绩记录薄 ");
|
|
printf("\n\n\t\t\t");
|
|
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[8]在原文件基础上添加学生信息\n");
|
|
printf("\t\t\t[9]退出成绩记录薄\n");
|
|
printf("\t\t\t");
|
|
for(i=0; i<32; i++)
|
|
printf("-");
|
|
printf("\n\n");
|
|
printf("\n\t\t\t请输入选项:");
|
|
scanf("%d",&n);
|
|
return n;
|
|
}
|
|
|
|
void input() {
|
|
system("cls");
|
|
i=0;
|
|
fp=fopen("stuinfo","w");
|
|
printf("*结束请在学号、姓名、成绩栏输入 0*\n");
|
|
do {
|
|
printf("输入学生的学号:");
|
|
scanf("%d",&s[i].num);
|
|
printf("输入学生的姓名:");
|
|
scanf("%s",s[i].name);
|
|
printf("输入学生的 C 语言成绩:");
|
|
scanf("%lf",&s[i].cscore);
|
|
if(s[i].num!=0)
|
|
fprintf(fp,"%d%-4s%.1lf\n",s[i].num,s[i].name,s[i].cscore);
|
|
} while(s[i].num!=0);
|
|
fclose(fp);
|
|
}
|
|
|
|
void output() {
|
|
if((fp=fopen("stuinfo","r"))==NULL) {
|
|
printf("打不开文件!\n");
|
|
}
|
|
printf("\t\t\t 全部的学生信息:\n");
|
|
k=0;
|
|
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=EOF) {
|
|
printf("\t\t\t%d\t%s\t%.1lf\n",s[k].num,s[k].name,s[k].cscore);
|
|
k++;
|
|
}
|
|
fclose(fp);
|
|
}
|
|
|
|
void add() {
|
|
system("cls");
|
|
i=0;
|
|
fp=fopen("stuinfo","a");
|
|
printf("*结束请在学号、姓名、成绩栏输入 0*\n");
|
|
do {
|
|
printf("输入学生的学号:");
|
|
scanf("%d",&s[i].num);
|
|
printf("输入学生的姓名:");
|
|
scanf("%s",s[i].name);
|
|
printf("输入学生的 C 语言成绩:");
|
|
scanf("%lf",&s[i].cscore);
|
|
if(s[i].num!=0)
|
|
fprintf(fp,"%d%-4s%.1lf\n",s[i].num,s[i].name,s[i].cscore);
|
|
} while(s[i].num!=0);
|
|
fclose(fp);
|
|
}
|