#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct person
{
char num[10];
char name[20];
float cyuyan;
float en;
float ji;
float guti;
}person;
person per[200];
char filename[20];
#include<stdlib.h>
#include<string.h>
typedef struct person
{
char num[10];
char name[20];
float cyuyan;
float en;
float ji;
float guti;
}person;
person per[200];
char filename[20];
int menu_select()
{
char c;
do{
system("cls");
printf("\t ╭═══════════■□■□═════════════╮\n");
printf("\t│ 学生信息管理系统 │\n");
printf("\t╰ ═══════════■□■□═════════════ ╯\n");
printf("\t ┌────────────────────────────┐\n");
printf("\t │ 1. 添加记录 2. 显示记录 │\n");
printf("\t │ │\n");
printf("\t │ 3. 信息查询 4. 数据计算 │\n");
printf("\t │ │\n");
printf("\t │ 5. 删除记录 0. 退出程序 │\n");
printf("\t │ │\n");
printf("\t └────────────────────────────┘\n");
printf("\t 请您选择(0-5):");
c = getchar();
printf("\n");
} while (c<'0' || c>'5');
return (c - '0');
}
{
char c;
do{
system("cls");
printf("\t ╭═══════════■□■□═════════════╮\n");
printf("\t│ 学生信息管理系统 │\n");
printf("\t╰ ═══════════■□■□═════════════ ╯\n");
printf("\t ┌────────────────────────────┐\n");
printf("\t │ 1. 添加记录 2. 显示记录 │\n");
printf("\t │ │\n");
printf("\t │ 3. 信息查询 4. 数据计算 │\n");
printf("\t │ │\n");
printf("\t │ 5. 删除记录 0. 退出程序 │\n");
printf("\t │ │\n");
printf("\t └────────────────────────────┘\n");
printf("\t 请您选择(0-5):");
c = getchar();
printf("\n");
} while (c<'0' || c>'5');
return (c - '0');
}
void add()
{
FILE *fp;
int i = 0, n = 0;
char sign = 'y';
system("cls");
person p[200];
while (sign != 'n'&&sign != 'N')
{
printf(" ----学生纪录添加----\n");
printf("姓名:\n");
scanf("\t%s", p[i].name);
printf("学号:\n");
scanf("\t%s", p[i].num);
printf("A类奖:\n");
scanf("\t%f", &p[i].cyuyan);
printf("B类奖:\n");
scanf("\t%f", &p[i].en);
printf("C类奖:\n");
scanf("\t%f", &p[i].ji);
printf("D类奖:\n");
scanf("\t%f", &p[i].guti);
printf("是否继续添加?(y/n)");
scanf("\t%c", &sign);
i++;
n = n + 1;
system("cls ");
}
system("pause");
{
FILE *fp;
int i = 0, n = 0;
char sign = 'y';
system("cls");
person p[200];
while (sign != 'n'&&sign != 'N')
{
printf(" ----学生纪录添加----\n");
printf("姓名:\n");
scanf("\t%s", p[i].name);
printf("学号:\n");
scanf("\t%s", p[i].num);
printf("A类奖:\n");
scanf("\t%f", &p[i].cyuyan);
printf("B类奖:\n");
scanf("\t%f", &p[i].en);
printf("C类奖:\n");
scanf("\t%f", &p[i].ji);
printf("D类奖:\n");
scanf("\t%f", &p[i].guti);
printf("是否继续添加?(y/n)");
scanf("\t%c", &sign);
i++;
n = n + 1;
system("cls ");
}
system("pause");
if ((fp = fopen("studata.txt", "a")) == NULL)
{
printf("cannot open the files\n");
system("pause");
return;
}
for (i = 0; i<n; i++)
{
fprintf(fp, "%s %s %f %f %f %f ", p[i].name, p[i].num, p[i].cyuyan, p[i].en, p[i].ji, p[i].guti);
{
printf("cannot open the files\n");
system("pause");
return;
}
for (i = 0; i<n; i++)
{
fprintf(fp, "%s %s %f %f %f %f ", p[i].name, p[i].num, p[i].cyuyan, p[i].en, p[i].ji, p[i].guti);
}
fclose(fp);
system("pasue");
}
system("pasue");
}
void scan()
{
void amend();
{
void amend();
char sign = 'y';
FILE *fp;
int n;
system("cls");
if ((fp = fopen("studata.txt", "r")) == NULL)
{
printf("cannot open the files\n");
system("pause");
return;
}
FILE *fp;
int n;
system("cls");
if ((fp = fopen("studata.txt", "r")) == NULL)
{
printf("cannot open the files\n");
system("pause");
return;
}
i