分登陆界面的学生成绩管理系统~ 输入密码后不显示菜单啊~求帮助!!!
#include<stdio.h>#include<string.h>
#include<conio.h>
#include<stdlib.h>
void ADD_A();//函数声明
void LOGIN();
void Function(char num[11],char name[20]);
void Teacher(char card[11]);
void AddScore(char course[20]);
void CheckScore(char course[20]);
void ModifyScore(char course[20]);
void AnalysisScore(char course[20]);
void Student(char card[11],char name[20]);
void SearchScore(char card[20]);
void Instructor(char card[11],char name[20]);
void LookScore(char card[20]);
void AnalyseScore(char card[20]);
void ScanFail(char card[20]);
int compare_math(const void *arg1,const void *arg2);
int compare_english(const void *arg3,const void *arg4);
int compare_computer(const void *arg5,const void *arg6);
int compare_ave(const void *arg1,const void *arg2);
struct load
{
char card[11];
char name[20];
char password[7];
char right;
};
struct teacher
{
char card[11];
char name[20];
char password[7];
char right;
char course[20];
};
struct student
{
char card[11];//学号
char name[20];//姓名
char password[7];//密码
double Smath;//课程相应分数
double Senglish;
double Scomputer;
double sum;//总分
double ave;//平均分数
char math[20];//课程
char english[20];
char computer[20];
};
struct instructor
{
char card[11];
char name[20];
char password[7];
char right;
};
//============================主函数============================//
int main()
{
//ADD_DATA();
LOGIN();
load in;
return 0;
}
//=========================添加用户信息=========================//
void ADD_DATA()
{
FILE *fpDest;
fpDest=fopen("D:\\load.txt","wb");
int n=3;
while(n--)
{
load in;
printf("请输入所要添加的用户号:\n");
gets(in.card);
printf("请输入姓名:\n");
gets(in.name);
printf("请输入密码:\n");
gets(in.password);
printf("请输入权限值:\n");
in.right=getchar();
getchar();//读取回车键。
fwrite(&in,sizeof(in),1,fpDest);
}
}
//===========================登陆===============================//
void LOGIN()
{
int i;
load in;
char card[11];
char password[7];
FILE *fpSrc;
printf("*********欢迎进入***********\n");
printf("******学生成绩管理系统******\n");
printf("请输入用户号:\n");
gets(card);
printf("请输入密码:\n");
for(i=0;i<6;i++)//循环。
{
password[i]=getch();
printf("*");
}
password[6]='\0';//由0开始
fpSrc=fopen("D:\\load.txt","r");
while(fread(&in,sizeof(in),1,fpSrc))
{
if(!strcmp(in.card,card) && !strcmp(in.password,password))
{
fclose(fpSrc);
return;
}
}
fclose(fpSrc);
return;
}
//==========================权限判断==========================//
void Function(char card[11])
{
int right;
student stu;
teacher tea;
instructor ins;
switch(right)
{
case 1:
Teacher(tea.card);//函数调用
break;
case 2:
Student(stu.card,stu.name);
break;
case 3:
Instructor(ins.card,ins.name);
break;
}
}
//==============================教师============================//
void Teacher(char card[11])
{
printf("******欢迎进入********\n");
printf("*****学生成绩管理系统*****\n");
printf("***** 1.成绩录入 *****\n");
printf("***** 2.成绩查看 *****\n");
printf("***** 3.成绩修改 *****\n");
printf("***** 4.成绩分析 *****\n");
printf("***** 5.保存信息到文件**\n");
printf("***** 6.点击退出 *****\n");
FILE *fpT;
fpT=fopen("D:\\teacher.txt","r+");
getch();
teacher in;
while(fread(&in,sizeof(in),1,fpT))
{
if(!strcmp(in.card,card))
break;
}
fclose(fpT);
printf("请输入您的选项:\n");
int input;
scanf("%d",&input);
switch(input)
{
case 1:
AddScore(in.course);
break;
case 2:
CheckScore(in.course);
break;
case 3:
ModifyScore(in.course);
break;
case 4:
AnalysisScore(in.course);
break;
case 5:
printf("按任意键退出\n");
getchar();
break;
default:
printf("选项输入错误,请重输:\n");
break;
return ;
FILE *fpS;
if((fpS=fopen("D:\\student.txt","r")) == NULL)
{
printf("Cannot open this file!\n");
return ;
}
student in;
while(fread(&in,sizeof(in),1,fpS))
{
in.sum=in.Smath+in.Scomputer+in.Senglish;
in.ave=in.sum/3;
fseek(fpS,-sizeof(in),SEEK_CUR);
fwrite(&in,sizeof(in),1,fpS);
fseek(fpS,sizeof(in),SEEK_CUR);
}
fclose(fpS);
}
}
void AddScore(char course[20])//录入成绩
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
if(fpS==NULL)
{
printf("Cannot open this file!\n");
return;
}
student in;
while(fread(&in,sizeof(in),1,fpS))
{
if(!strcmp(course,in.math))
{
printf("请输入该科成绩:\n");
printf("课程名:%s 学号:%s 姓名:%s \n",in.math,in.card,in.name);
}
if(!strcmp(course,in.english))
{
printf("请输入该科成绩:\n");
printf("课程名:%s 学号:%s 姓名:%s \n",in.english,in.card,in.name);
}
if(!strcmp(course,))
{
printf("请输入该科成绩:\n");
printf("课程名:%s 学号:%s 姓名:%s \n",,in.card,in.name);
}
fseek(fpS,-sizeof(in),SEEK_CUR);
fwrite(&in,sizeof(in),1,fpS);
fseek(fpS,sizeof(in),SEEK_CUR);
}
fclose(fpS);
printf("成绩录入成功!\n");
return;
}
void CheckScore(char course[20])//查看成绩
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
if(fpS==NULL)
{
printf("Cannot open this file!\n");
getchar();
return;
}
student in;
while(fread(&in,sizeof(in),1,fpS))
{
if(!strcmp(in.math,course))
{
printf("%s %s %s %f\n",in.card,in.name,in.math,in.Smath);
continue;
}
if(!strcmp(in.english,course))
{
printf("%s %s %s %f\n",in.card,in.name,in.english,in.Senglish);
continue;
}
if(!strcmp(,course))
{
printf("%s %s %s %f\n",in.card,in.name,,in.Scomputer);
continue;
}
}
fclose(fpS);
}
void ModifyScore(char course[20])//修改成绩
{
printf("请输入所要修改学生的学号:\n");
char card[20];
gets(card);
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
if(fpS==NULL)
{
printf("Cannot open this file!\n");
return;
}
student in;
while(fread(&in,sizeof(in),1,fpS))
{
if(!strcmp(card,in.card))
{
if(!strcmp(course,in.math))
{
printf("科目:%s 学号:%s 姓名:%s 分数:%f \n",in.math,in.card,in.name,in.Smath);
int sc;
printf("请输入修改后的%s分数:\n",in.math);
scanf("%d",&sc);
in.Smath=sc;
break;
}
if(!strcmp(course,in.english))
{
printf("科目:%s 学号:%s 姓名:%s 分数:%f \n",in.english,in.card,in.name,in.Senglish);
int sc;
printf("请输入修改后的%s成绩:",in.english);
scanf("%d",&sc);
in.Senglish=sc;
break;
}
if(!strcmp(course,))
{
printf("科目:%s 学号:%s 姓名:%s 分数:%f \n",,in.card,in.name,in.Scomputer);
int sc;
printf("请输入修改后的%s成绩:",);
scanf("%d",&sc);
in.Scomputer=sc;
break;
}
}
}
fseek(fpS,-sizeof(in),SEEK_CUR);
fwrite(&in,sizeof(in),1,fpS);
fclose(fpS);
printf("修改成功!");
}
void AnalysisScore(char course[20])//分析成绩
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
if(fpS==NULL)
{
printf("Cannot open this file!\n");
return;
}
student in[100];
int i=0;
while(fread(&in[i],sizeof(in),1,fpS))
{
i++;
}
if(!strcmp(course,in[i].math))
{
qsort(in,i,sizeof(in),compare_math);//快速排名?
printf("学号:\t 姓名:\t 课程:\t 分数:\t 名次:\t");
for(int ii=0;ii<i;i++)//ii?
{
printf("%s\t%s\t%s\t%f\t%d\t\n",in[ii].card,in[ii].name,in[ii].math,in[ii].Smath,ii+1);
}
}
else if(!strcmp(course,in[i].english))
{
qsort(in,i,sizeof(in),compare_english);
printf("学号:\t 姓名:\t 课程:\t 分数:\t 名次:\t");
for(int ii=0;ii<i;i++)
{
printf("%s\t%s\t%s\t%f\t%d\t\n",in[ii].card,in[ii].name,in[ii].english,in[ii].Senglish,ii+1);
}
}
else if(!strcmp(course,in[i].computer))
{
qsort(in,i,sizeof(in),compare_computer);
printf("学号:\t 姓名:\t 课程:\t 分数:\t 名次:\t");
for(int ii=0;ii<i;i++)
{
printf("%s\t%s\t%s\t%f\t%d\t\n",in[ii].card,in[ii].name,in[ii].computer,in[ii].Scomputer,ii+1);
}
}
getchar();//?
}
int compare_math(const void *arg1,const void *arg2)//const为强制转
{
return ((student *)arg1)->Smath < ((student *)arg2)->Smath;
}
int compare_english(const void *arg3,const void *arg4)
{
return ((student *)arg3)->Senglish< ((student *)arg4)->Senglish;
}
int compare_computer(const void *arg5,const void *arg6)
{
return ((student *)arg5)->Scomputer< ((student *)arg6)->Scomputer;
}
//=============================学生===============================//
void Student(char card[11],char name[20])
{
printf("*********欢迎进入*********\n");
printf("*****学生成绩管理系统*****\n");
printf("***** 1.成绩查询 *****\n");
printf("***** 2.点击退出 *****\n");
student in;
FILE *fpS;
fpS = fopen("D:\\student.txt","r");
while(fread(&in,sizeof(in),1,fpS))
{
if(!strcmp(in.card,card))
break;
}
fclose(fpS);
printf("请输入您的选项:\n");
int input;
scanf("%d",&input);
switch(input)
{
case 1:
SearchScore(in.card);
break;
case 2:
printf("按任意键退出\n");
getchar();
break;
default:
printf("选项输入错误,请重输:\n");
break;
}
return;
}
void SearchScore(char card[20])//查询成绩
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
student in;
while(fread(&in,sizeof(in),1,fpS))
{
if(!strcmp(in.card,card))
{
printf("%s %s\n",in.card,in.name);
printf("%s %f\n%s %f\n %s %f\n %f %f\n",in.math,in.Smath,in.english,in.Senglish,,in.Scomputer,in.sum,in.ave);
fclose(fpS);
return;
}
}
}
//==========================辅导员===========================//
void Instructor(char card[11],char name[20])
{
printf("**************欢迎进入************\n");
printf("*********学生成绩管理系统*********\n");
printf("***** 1.所有学生成绩查看 *****\n");
printf("***** 2.所有学生成绩分析 *****\n");
printf("***** 3.挂科学生情况查看 *****\n");
printf("***** 4.点击退出 *****\n");
instructor ins;
printf("请输入您的选项:\n");
int input;
scanf("%d",&input);
switch(input)
{
case 1:
LookScore(ins.card);
break;
case 2:
AnalyseScore(ins.card);
break;
case 3:
ScanFail(ins.card);
case 4:
printf("按任意键退出\n");
getchar();
break;
default:
printf("选项输入错误,请重输:\n");
break;
}
return;
}
void LookScore(char card[20])//查看成绩
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
if(fpS==NULL)
{
printf("Cannot open this file!");
return;
}
student in;
printf("学号\t 姓名\t 高数\t 分数\t 英语\t 分数\t 计算机\t 分数\t 总分\t 平均分\t\n");
while(fread(&in,sizeof(in),1,fpS))
{
printf("%s\t %s\t %s\t %f\t %s\t %f\t %s\t %f\t %f\t %f\t\n",in.card,in.name,in.math,in.Smath,in.english,in.Senglish,,in.Scomputer,in.sum,in.ave);
}
fclose(fpS);
}
void AnalyseScore(char card[20])//分析成绩
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
student in[100];
int i=1;
while(fread(&in[i],sizeof(in),1,fpS))
{
i++;
}
qsort(in,i,sizeof(in),compare_ave);
printf("学号\t 姓名\t 高数\t 分数\t 英语\t 分数\t 计算机\t 分数\t 总分\t 平均分\t 名次\t\n");
for(int ii=1;ii<i;ii++)
{
printf("%s\t %s\t %s\t %f\t %s\t %f\t %s\t %f\t %f\t %f\t %d\t\n",in[ii].card,in[ii].name,in[ii].math,in[ii].Smath,in[ii].english,in[ii].Senglish,
in[ii].computer,in[ii].Scomputer,in[ii].sum,in[ii].ave,ii);
}
return;
}
void ScanFail(char card[20])//查看挂科学生
{
FILE *fpS;
fpS=fopen("D:\\student.txt","r");
if(fpS==NULL)
{
printf("Cannot open this file!");
getchar();
return;
}
student in;
printf("学号\t 姓名\t 高数\t 分数\t 英语\t 分数\t 计算机\t 分数\t 总分\t 平均分\t\n");
while(fread(&in,sizeof(in),1,fpS))
{
if(in.Smath<60 || in.Senglish<60 || in.Scomputer<60)
printf("%s\t %s\t %s\t %f\t %s\t %f\t %s\t %f\t %f\t %f\t\n",in.card,in.name,in.math,in.Smath,in.english,in.Senglish,,in.Scomputer,in.sum,in.ave);
}
return;
}
int compare_ave(const void *arg1,const void *arg2)
{
return ((student *)arg1)->ave < ((student *)arg2)->ave;
}