|
|
@ -0,0 +1,735 @@
|
|
|
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
|
|
|
#include<string.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char name[20]; //学生姓名
|
|
|
|
|
|
|
|
char xuehao[20]; //学生学号
|
|
|
|
|
|
|
|
char phone[20]; //学生手机号
|
|
|
|
|
|
|
|
char qq[20]; //学生QQ号
|
|
|
|
|
|
|
|
int score[3]; //学生的三门课成绩
|
|
|
|
|
|
|
|
int sum; //学生三门课成绩的总和
|
|
|
|
|
|
|
|
}STU;
|
|
|
|
|
|
|
|
int addstu(); //增添学生信息
|
|
|
|
|
|
|
|
void stupaixu(); //将学生信息按分数由高到低显示
|
|
|
|
|
|
|
|
int xhcz(); //用学号进行查找
|
|
|
|
|
|
|
|
int namecz(); //用姓名查询
|
|
|
|
|
|
|
|
int xxxg(); //搜索学号,并对该生的信息进行修改
|
|
|
|
|
|
|
|
int shanchu(); //搜索学号,删除该生所有信息
|
|
|
|
|
|
|
|
void fsdxs(); //分数段显示 成绩
|
|
|
|
|
|
|
|
int menu(); //菜单函数
|
|
|
|
|
|
|
|
int stdk(); //学生端口界面
|
|
|
|
|
|
|
|
int tedk(); //教师端口界面
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("color f1"); //包含于头文件 <stdlib.h> 两个16进制的数来换颜色,第一个是背景颜色,第二个是字体颜色
|
|
|
|
|
|
|
|
menu(); //调用菜单界面函数
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(menu()) //将菜单界面 用户输入的需求返回值进行选择
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入学生界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
stdk(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入教师界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
tedk(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
printf("\n\t\t欢迎再次使用!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int menu() //菜单函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char xuanze; //定义一个 字符型 的"选择", 用于接收用户的需求
|
|
|
|
|
|
|
|
int xz; //定义一个 整型 的"选择", 作为 字符型选择的 返回值
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls"); //清屏
|
|
|
|
|
|
|
|
printf("\n\t\t************湖南工业大学信息管理系统************\n");
|
|
|
|
|
|
|
|
printf("\t\t*┌-------------------------------------------┐ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 请问您的身份是: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 1.学生 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 2.教师 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 0.退出 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*└-------------------------------------------┘ *\n");
|
|
|
|
|
|
|
|
printf("\t\t************************************************\n");
|
|
|
|
|
|
|
|
printf("\t\t请您选择(0-2):");
|
|
|
|
|
|
|
|
fflush(stdin); //防止用户一次性输入多个字符
|
|
|
|
|
|
|
|
scanf("%c", &xuanze); //查看用户的身份,进入下一界面
|
|
|
|
|
|
|
|
}while(xuanze<'0' || xuanze>'2'); //检查输入是否符合规范
|
|
|
|
|
|
|
|
xz = xuanze-'0'; //将字符型的选择转换成整型
|
|
|
|
|
|
|
|
switch(xz) //将整型返回值进行 "选择"
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入学生界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
stdk(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入教师界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
tedk(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
printf("\n\t\t欢迎再次使用!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int addstu() //增添学生信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp1=NULL, *fp=NULL; //定义两个文件指针
|
|
|
|
|
|
|
|
STU st[1000]; //定义一个零时结构体数组,用来存储从文件读入的学生信息
|
|
|
|
|
|
|
|
int n, k=0, q; // n 用来存储需要添加的学生人数
|
|
|
|
|
|
|
|
// k 用来计算原文件中的学生总数
|
|
|
|
|
|
|
|
// q 用来做循环的整型变量
|
|
|
|
|
|
|
|
char names[20]; //定义零时姓名字符串,用于零时存储学生姓名
|
|
|
|
|
|
|
|
char xuehaos[20]; //定义零时学号字符串,用于零时存储学生学号
|
|
|
|
|
|
|
|
if((fp1 = fopen("xsxx.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\tError\n\n\t\t");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp1))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp1,"%s %s %s %s %d %d %d %d",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //每读入一个学生信息,学生总数加一
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp1);
|
|
|
|
|
|
|
|
printf("\n\t\t请输入要增添的学生人数:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%d",&n); //读入需要添加的学生人数
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
for(int i=0; i<n; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","a+"))==NULL) //以 "a+" 的方式打开文件,添加学生信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Error\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生姓名:\n\n\t\t");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
scanf("%s",&names);
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生学号:\n\n\t\t");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
scanf("%s",&xuehaos); //读入零时学号,与原文件中的所有学生学号进行比对,如果不唯一则不能添加
|
|
|
|
|
|
|
|
for(q=0; q<=k; q++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(xuehaos,st[q].xuehao)==0) //将用户输入的学号与原文件中的学号进行比对
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t该学号已存在,无法添加!!!\n\n\t\t");
|
|
|
|
|
|
|
|
printf("\n\t\t将返回上一界面\n\n\t\t");
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
system("pause"); //要让用户知道为什么不能添加,所以暂停一下
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
return main(); //用户知道了就可以返回主界面了
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp,"%s ",names); //如果新添加的学号是唯一的,一次性将新学生的
|
|
|
|
|
|
|
|
fprintf(fp,"%s ",xuehaos); // "姓名" 和 "学号" 都存到文件中去
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生手机号:\n\n\t\t");
|
|
|
|
|
|
|
|
fflush(stdin); //每一次输入前都要清空缓存区,防止发生意外情况
|
|
|
|
|
|
|
|
scanf("%s",&st[i].phone); //在确定过学号唯一之后,就可以将以下的信息直接写入文件了
|
|
|
|
|
|
|
|
fprintf(fp,"%s ",st[i].phone);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生QQ号:\n\n\t\t");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
scanf("%s",&st[i].qq);
|
|
|
|
|
|
|
|
fprintf(fp,"%s ",st[i].qq);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生三门课的成绩:\n\n\t\t");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
scanf("%d %d %d",&st[i].score[0], &st[i].score[1], &st[i].score[2]);
|
|
|
|
|
|
|
|
st[i].sum = (st[i].score[0] + st[i].score[1] + st[i].score[2]);
|
|
|
|
|
|
|
|
fprintf(fp,"%d %d %d %d\n",st[i].score[0], st[i].score[1], st[i].score[2], st[i].sum);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void stupaixu() //显示所有学生成的绩并自动排序的函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp=NULL, *fp1 = NULL; //定义文件指针 *fp 用来读文件, *fp1 用来将排序后的信息写入文件
|
|
|
|
|
|
|
|
STU st[1000], temp; //定义零时结构体数组
|
|
|
|
|
|
|
|
int i, j, k=0; // i , j, 用于作为循环变量, k 用于计数
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Error\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%s %s %s %s %d %d %d %d\n",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //学生总数加一
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<k-1; j++) //冒牌排序
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for(i=0; i<k-1-j; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(st[i].sum<st[i+1].sum)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
temp=st[i];
|
|
|
|
|
|
|
|
st[i]=st[i+1];
|
|
|
|
|
|
|
|
st[i+1]=temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if((fp1 = fopen("xsxx.txt","w"))==NULL) //将冒泡排序后的信息全部重新写入文件,覆盖原有的信息
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Error\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int o=0; o<k; o++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(fp1,"%s %s %s %s %d %d %d %d\n",st[o].name,st[o].xuehao,st[o].phone,st[o].qq,st[o].score[0], st[o].score[1],st[o].score[2],st[o].sum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp1);
|
|
|
|
|
|
|
|
printf("\n\t\t********************************学生信息******************************\n");
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
for(int t=0; t<k; t++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t第%d名:\n",t+1);
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t学号:%-16s\n",st[t].name,st[t].xuehao);
|
|
|
|
|
|
|
|
printf("\t\t手机号:%-16s\tQQ号:%-16s\n",st[t].phone,st[t].qq);
|
|
|
|
|
|
|
|
for(int s=0; s<3; s++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t");
|
|
|
|
|
|
|
|
printf("第%d科目成绩:%3d",s+1,st[t].score[s]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t总分:%d\n",st[t].sum);
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int xhcz() //用学号查找信息的函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp=NULL; //定义文件指针
|
|
|
|
|
|
|
|
STU st[1000], tempa; //定义零时结构体数组,零时结构体
|
|
|
|
|
|
|
|
int i, k=0; // k 用于计算学生总数
|
|
|
|
|
|
|
|
char xuehaos[20]; //定义零时 学号 字符串
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Error\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%s %s %s %s %d %d %d %d",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //学生总数加一
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生学号:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xuehaos); //存储用户输入的学号
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
for(i=0; i<=k; i++) //循环判断学号是否匹配
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(xuehaos,st[i].xuehao)==0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i>k) // i > k 时,即整个文件所有学号都没有匹配的,执行此步骤
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t查无此人!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause"); //暂停一下,让用户知道为啥返回主界面
|
|
|
|
|
|
|
|
return main(); //返回主界面
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else // i < k 时,说明有匹配的人,他时第 i 个人
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t********************************学生信息******************************\n");
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t学号:%-16s\n",st[i].name,st[i].xuehao);
|
|
|
|
|
|
|
|
printf("\t\t手机号:%-16s\tQQ号:%-16s\n",st[i].phone,st[i].qq);
|
|
|
|
|
|
|
|
for(int s=0; s<3; s++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t");
|
|
|
|
|
|
|
|
printf("第%d科目成绩:%3d",s+1,st[i].score[s]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t总分:%d\n",st[i].sum);
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\n\t\t");
|
|
|
|
|
|
|
|
system("pause"); //先让用户看够了,然后按任意键返回
|
|
|
|
|
|
|
|
return main(); //返回主界面
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int xxxg() //修改信息的函数 == "学号 修改"的拼音
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp=NULL, *fp2=NULL; //定义两个文件指针
|
|
|
|
|
|
|
|
STU st[1000], tempa; //定义一个零时结构体数组,一个零时结构体
|
|
|
|
|
|
|
|
int n, i, j, k=0, x; // k用于计数
|
|
|
|
|
|
|
|
int km1, km2, km3, q, r; //科目1,科目2,科目3,两个用于循环的整型变量
|
|
|
|
|
|
|
|
char xuehaos[20], xiugais[20]; //定义一个零时 学号字符串,一个 "修改"字符串
|
|
|
|
|
|
|
|
char xuanze; //字符型 选择
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Error\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%s %s %s %s %d %d %d %d",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //每读入一个学生信息总数加一
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
printf("\n\t\t请输入需要修改信息的学生学号:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xuehaos); //读入用户想要修改人的学号
|
|
|
|
|
|
|
|
for(i=0; i<=k; i++) //循环查找这个人
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(xuehaos,st[i].xuehao)==0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i>k)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t查无此人!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
return main();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t********************************学生信息******************************\n");
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t学号:%-16s\n",st[i].name,st[i].xuehao);
|
|
|
|
|
|
|
|
printf("\t\t手机号:%-16s\tQQ号:%-16s\n",st[i].phone,st[i].qq);
|
|
|
|
|
|
|
|
for(int s=0; s<3; s++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t");
|
|
|
|
|
|
|
|
printf("第%d科目成绩:%3d",s+1,st[i].score[s]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t总分:%d\n",st[i].sum);
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\n\t\t************************************************\n");
|
|
|
|
|
|
|
|
printf("\t\t*┌-------------------------------------------┐ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 请选择您需要的服务: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 1.修改姓名: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 2.修改学号: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 3.修改手机号: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 4.修改QQ号: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 5.修改成绩: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 0.返回上一界面 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*└-------------------------------------------┘ *\n");
|
|
|
|
|
|
|
|
printf("\t\t************************************************\n");
|
|
|
|
|
|
|
|
printf("\n\t\t请输入需要修改的信息:\n\t\t");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
scanf("%c", &xuanze);
|
|
|
|
|
|
|
|
x = xuanze - '0';
|
|
|
|
|
|
|
|
switch(x)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
printf("\n\t\t请输入新的姓名:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xiugais);
|
|
|
|
|
|
|
|
strcpy(st[i].name, xiugais);
|
|
|
|
|
|
|
|
printf("\n\t\t修改成功!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
printf("\n\t\t请输入新的学号:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xiugais);
|
|
|
|
|
|
|
|
for(q=0; q<=k; q++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(xiugais,st[q].xuehao)==0) //判断是否与文件中的学号冲突
|
|
|
|
|
|
|
|
{ //将新学号与文件中所有学号进行比对,如果重复了就不能成功修改
|
|
|
|
|
|
|
|
printf("\n\t\t该学号已存在,无法修改!!!\n\n\t\t");
|
|
|
|
|
|
|
|
printf("\n\t\t将返回上一界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
return main(); //返回主界面
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(st[i].xuehao, xiugais); //如果不冲突,就修改
|
|
|
|
|
|
|
|
printf("\n\t\t修改成功!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
printf("\n\t\t请输入新手机号:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xiugais);
|
|
|
|
|
|
|
|
strcpy(st[i].phone, xiugais);
|
|
|
|
|
|
|
|
printf("\n\t\t修改成功!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
printf("\n\t\t请输入新的QQ号:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xiugais);
|
|
|
|
|
|
|
|
strcpy(st[i].qq, xiugais);
|
|
|
|
|
|
|
|
printf("\n\t\t修改成功!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
|
|
printf("\n\t\t请输入新的三门科目成绩:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%d %d %d", &km1, &km2, &km3); //将新的三门科目的成绩赋给第 i 个人的成绩里面
|
|
|
|
|
|
|
|
st[i].score[0] = km1;
|
|
|
|
|
|
|
|
st[i].score[1] = km2;
|
|
|
|
|
|
|
|
st[i].score[2] = km3;
|
|
|
|
|
|
|
|
st[i].sum = km1 + km2 + km3;
|
|
|
|
|
|
|
|
printf("\n\t\t修改成功!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
system("cls"); //成功修改了之后,将这个人的信息显示出来
|
|
|
|
|
|
|
|
printf("\n\t\t********************************学生信息******************************\n");
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t学号:%-16s\n",st[i].name,st[i].xuehao);
|
|
|
|
|
|
|
|
printf("\t\t手机号:%-16s\tQQ号:%-16s\n",st[i].phone,st[i].qq);
|
|
|
|
|
|
|
|
for(int s=0; s<3; s++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t");
|
|
|
|
|
|
|
|
printf("第%d科目成绩:%3d",s+1,st[i].score[s]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t总分:%d\n",st[i].sum);
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\n\t\t");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if((fp2 = fopen("xsxx.txt","w"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\tError\n\n\t\t");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int o=0; o<k-1; o++) //将修改后的所有学生信息循环写入文件
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(fp2,"%s %s %s %s %d %d %d %d\n",st[o].name,st[o].xuehao,st[o].phone,st[o].qq,st[o].score[0], st[o].score[1],st[o].score[2],st[o].sum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int shanchu() //删除学生信息的函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp=NULL; //定义文件指针
|
|
|
|
|
|
|
|
STU st[1000], tempa; //定义一个零时结构体数组, 一个零时结构体
|
|
|
|
|
|
|
|
int i, k=0; // i 是用于循环的变量, k 是用于计算学生总数的变量
|
|
|
|
|
|
|
|
char xuehaos[20]; //定义一个用户输入的学号,与文件中的进行比对
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\tError\n\n\t\t");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%s %s %s %s %d %d %d %d",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //每从文件读入一个学生,学生总数加一
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
printf("\n\t\t请输入需要删除信息的学生学号:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &xuehaos);
|
|
|
|
|
|
|
|
for(i=0; i<=k; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(xuehaos,st[i].xuehao)==0) //判断学号是否匹配
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i>k) //如果 i > k ,说明整个文件所有的学生信息对比完,都没有一个能匹配,执行此步骤
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t查无此人!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause"); //让用户知道为啥不能删除
|
|
|
|
|
|
|
|
return main();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else //此步骤是将删除信息后的零时结构体输入重新全部写入文件
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\t删除成功!\n\n\t\t");
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","w"))==NULL) //以 "w" 的方式打开,完全覆盖原文件
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\tError\n\n\t\t");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int o=0; o<k-2; o++) //原来有 k 个学生,现在 要在原来的基础上-1
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(st[o].xuehao,xuehaos)==0) //如果学号匹配到要删除的学生学号,执行此步骤
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for(int j=i; j<k-2; j++) //循环要删除的那个学生后面的学生信息赋给前一个
|
|
|
|
|
|
|
|
st[j]=st[j+1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp,"%s %s %s %s %d %d %d %d\n",st[o].name,st[o].xuehao,st[o].phone,st[o].qq,st[o].score[0], st[o].score[1],st[o].score[2],st[o].sum);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fsdxs() //fsdxs==分数段显示
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp1=NULL, *fp=NULL;
|
|
|
|
|
|
|
|
STU st[1000];
|
|
|
|
|
|
|
|
int n, k=0, q, i, s=0; //s是开关,控制是否显示分数段无人的情况
|
|
|
|
|
|
|
|
float ave=0; //定义一个平均分
|
|
|
|
|
|
|
|
if((fp1 = fopen("xsxx.txt","r"))==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\tError\n\n\t\t");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp1))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp1,"%s %s %s %s %d %d %d %d",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //先将文件中所有学生的信息读出来,存入零时结构体数组中
|
|
|
|
|
|
|
|
} //然后对应的进行选择输出
|
|
|
|
|
|
|
|
fclose(fp1);
|
|
|
|
|
|
|
|
printf("\n\t\t********************************学生信息******************************\n");
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t平均分90以上的人是:\n");
|
|
|
|
|
|
|
|
for(i=0; i<k-1; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ave = st[i].sum/3.0;
|
|
|
|
|
|
|
|
if(ave>=90)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t平均分:%5.2f\n", st[i].name, st[i].sum/3.0);
|
|
|
|
|
|
|
|
s = 1; //如果执行此步骤,就打开开关,就不会输出 "此分数段无人"的语句了
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ave = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s==0) //判断开关是否打开,如果未打开,就执行此步骤
|
|
|
|
|
|
|
|
printf("\t\t此分数段没有人!\n");
|
|
|
|
|
|
|
|
s = 0; //每一次都要重置开关
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t平均分80~90的人是:\n");
|
|
|
|
|
|
|
|
for(i=0; i<k-1; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ave = st[i].sum/3.0;
|
|
|
|
|
|
|
|
if(ave>=80 && ave<90)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t平均分:%5.2f\n", st[i].name, st[i].sum/3.0);
|
|
|
|
|
|
|
|
s = 1; //如果执行此步骤,就打开开关,就不会输出 "此分数段无人"的语句了
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ave = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s==0) //判断开关是否打开,如果未打开,就执行此步骤
|
|
|
|
|
|
|
|
printf("\t\t此分数段没有人!\n");
|
|
|
|
|
|
|
|
s = 0; //每一次都要重置开关
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t平均分70~80的人是:\n");
|
|
|
|
|
|
|
|
for(i=0; i<k-1; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ave = st[i].sum/3.0;
|
|
|
|
|
|
|
|
if(ave>=70 && ave<80)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t平均分:%5.2f\n", st[i].name, st[i].sum/3.0);
|
|
|
|
|
|
|
|
s = 1; //如果执行此步骤,就打开开关,就不会输出 "此分数段无人"的语句了
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ave = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s==0) //判断开关是否打开,如果未打开,就执行此步骤
|
|
|
|
|
|
|
|
printf("\t\t此分数段没有人!\n");
|
|
|
|
|
|
|
|
s = 0; //每一次都要重置开关
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t平均分60~70的人是:\n");
|
|
|
|
|
|
|
|
for(i=0; i<k-1; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ave = st[i].sum/3.0;
|
|
|
|
|
|
|
|
if(ave>=60 && ave<70)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t平均分:%5.2f\n", st[i].name, st[i].sum/3.0);
|
|
|
|
|
|
|
|
s = 1; //如果执行此步骤,就打开开关,就不会输出 "此分数段无人"的语句了
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ave = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s==0) //判断开关是否打开,如果未打开,就执行此步骤
|
|
|
|
|
|
|
|
printf("\t\t此分数段没有人!\n");
|
|
|
|
|
|
|
|
s = 0; //每一次都要重置开关
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t平均分低于60的人是:\n");
|
|
|
|
|
|
|
|
for(i=0; i<k-1; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ave = st[i].sum/3.0;
|
|
|
|
|
|
|
|
if(ave>=0 && ave<60)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t平均分:%5.2f\n", st[i].name, st[i].sum/3.0);
|
|
|
|
|
|
|
|
s = 1; //如果执行此步骤,就打开开关,就不会输出 "此分数段无人"的语句了
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ave = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(s==0) //判断开关是否打开,如果未打开,就执行此步骤
|
|
|
|
|
|
|
|
printf("\t\t此分数段没有人!\n\n\t\t");
|
|
|
|
|
|
|
|
printf("\n\t\t");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int stdk() //学生端口 "st == 学生, dk == 端口"
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char xuanze; //"选择"
|
|
|
|
|
|
|
|
int xz; //"选择的整型返回值"
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls"); //清屏
|
|
|
|
|
|
|
|
printf("\n\t\t************湖南工业大学信息管理系统************\n");
|
|
|
|
|
|
|
|
printf("\t\t*┌-------------------------------------------┐ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 请选择您需要的服务: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 1.显示所有学生的成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 2.按分数段显示成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 3.按学号查询成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 4.按姓名查询成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 0.返回上一界面 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*└-------------------------------------------┘ *\n");
|
|
|
|
|
|
|
|
printf("\t\t************************************************\n");
|
|
|
|
|
|
|
|
printf("\t\t请您选择(0-4):");
|
|
|
|
|
|
|
|
fflush(stdin); //防止用户一次性输入多个字符
|
|
|
|
|
|
|
|
scanf("%c", &xuanze); //查看用户的身份,进入下一界面
|
|
|
|
|
|
|
|
}while(xuanze<'0' || xuanze>'4'); //检查输入是否符合规范
|
|
|
|
|
|
|
|
xz = xuanze-'0'; //将字符型"选择"变成它的整型返回值
|
|
|
|
|
|
|
|
switch(xz) //将整型返回值进行 "选择"
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 显示所有成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
stupaixu(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按分数段显示成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
fsdxs(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按学号查询成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
xhcz(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按姓名查询成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
namecz(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
printf("\n\t\t正在为您返回上一界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
return main(); //返回主界面
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return stdk(); //返回学生端口
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int tedk() //教师端口 "te == 老师, dk == 端口"
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char xuanze; //"选择"
|
|
|
|
|
|
|
|
int xz; //"选择"的整型返回值
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls"); //清屏
|
|
|
|
|
|
|
|
printf("\n\t\t************湖南工业大学信息管理系统************\n");
|
|
|
|
|
|
|
|
printf("\t\t*┌-------------------------------------------┐ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 请选择您需要的服务: │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 1.显示所有学生的成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 2.按分数段显示成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 3.按学号查询成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 4.按姓名查询成绩信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 5.增添学生信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 6.修改学生信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 7.删除学生信息 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*│ 0.返回上一界面 │ *\n");
|
|
|
|
|
|
|
|
printf("\t\t*└-------------------------------------------┘ *\n");
|
|
|
|
|
|
|
|
printf("\t\t************************************************\n");
|
|
|
|
|
|
|
|
printf("\t\t请您选择(0-7):");
|
|
|
|
|
|
|
|
fflush(stdin); //防止用户一次性输入多个字符
|
|
|
|
|
|
|
|
scanf("%c", &xuanze); //查看用户的身份,进入下一界面
|
|
|
|
|
|
|
|
}while(xuanze<'0' || xuanze>'7'); //检查输入是否符合规范
|
|
|
|
|
|
|
|
xz = xuanze-'0'; //将字符型"选择"变成它的整型返回值
|
|
|
|
|
|
|
|
switch(xz) //将整型返回值进行 "选择"
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 显示所有成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
stupaixu(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按分数段显示成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
fsdxs(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按学号查询成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
xhcz(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按姓名查询成绩信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
namecz(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 增添学生信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
addstu(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按学号查询,修改信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
xxxg(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
|
|
|
|
printf("\n\t\t正在进入 按学号查询,删除信息界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls"); //先清屏
|
|
|
|
|
|
|
|
shanchu(); //再调用函数,显示界面
|
|
|
|
|
|
|
|
system("pause"); //将显示的界面固定住
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
printf("\n\t\t正在为您返回上一界面\n\n\t\t");
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
return main(); //返回主函数
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tedk(); //返回教师端口
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int namecz() //"cz == 查找",用"姓名"进行查找的函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fp=NULL; //定义文件指针
|
|
|
|
|
|
|
|
STU st[1000]; //零时储存数据的结构体数组
|
|
|
|
|
|
|
|
int i, k=0; //k 用于计算学生人数
|
|
|
|
|
|
|
|
char names[20]; //定义用户输入需查找的学生姓名,方便进行比对
|
|
|
|
|
|
|
|
if((fp = fopen("xsxx.txt","r"))==NULL) //从文件读出所有学生信息,存入零时结构体,进行比对
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n\t\tError\n\n\t\t");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%s %s %s %s %d %d %d %d",&st[k].name,&st[k].xuehao,&st[k].phone,&st[k].qq,&st[k].score[0], &st[k].score[1],&st[k].score[2],&st[k].sum);
|
|
|
|
|
|
|
|
k++; //每读入一个学生的信息,记录学生的总数
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
printf("\n\t\t请输入学生姓名:\n\n\t\t");
|
|
|
|
|
|
|
|
scanf("%s", &names);
|
|
|
|
|
|
|
|
for(i=0; i<=k; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(names,st[i].name)==0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i>k) //如果判断完所有人的姓名都对不上,执行此步骤
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("\n\t\t查无此人!\n\n\t\t");
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
|
|
return main();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else //如果 i < k 成立,就说明有匹配的,执行此步骤
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
system("cls"); //先清屏,再显示信息,就不乱了
|
|
|
|
|
|
|
|
printf("\n\t\t********************************学生信息******************************\n");
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\t\t姓名:%-16s\t学号:%-16s\n",st[i].name,st[i].xuehao);
|
|
|
|
|
|
|
|
printf("\t\t手机号:%-16s\tQQ号:%-16s\n",st[i].phone,st[i].qq);
|
|
|
|
|
|
|
|
for(int s=0; s<3; s++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\t\t");
|
|
|
|
|
|
|
|
printf("第%d科目成绩:%3d",s+1,st[i].score[s]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\t\t总分:%d\n",st[i].sum);
|
|
|
|
|
|
|
|
printf("\t\t----------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
printf("\n\t\t");
|
|
|
|
|
|
|
|
system("pause"); //先让用户看够了 , 然后按任意键返回
|
|
|
|
|
|
|
|
return main(); //输出结束后就返回主界面
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|