课程设计源代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
#include
#include
#define LEN sizeof(struct people)
#define SCH sizeof(struct school)
#define CLA sizeof(struct classes)
int n_n=0,n_n2=0,tc_=0; //为了读取而用的必要的全局变量
int ma_st=0;
char name[20],code[20];
//--------------------------------------------------------------------------------------
/* 题目5:教务信息管理系统
1、题目描述
设计一个教务信息管理系统,该程序具有以下功能:
(1)录入如下信息:学生基本信息:如学号、姓名、性别、年龄电、宿舍号码、话号码等。
课程基本信息:课程编号、课程名称、考试成绩、平时成绩、综合成绩、
学分、重修否等。如果重修,需要考虑重修学期、重修成绩,并且要考虑多次重修的情况。
(2)录入选课信息
(3)录入学生成绩
(3)按班统计学生选课情况及考试成绩。
(4)按课程统计学生名单及考试成绩。
(5)统计并输出每个同学已修学分及不及三格课程。
2、题目要求
(1)按照分析、设计、编码、调试和测试过程完成应用程序;
(2)学习并使用流程图等工具,并在撰写报告中使用;
(3)程序的各项功能在程序运行时,以菜单方式选择并执行;
(4)要求用户输入数据时,要给出清晰、明确的提示,包括:输入数据的内容、格式及结束方式等
(5)所有的信息存储在文件中,并实现文件读写操作。
(6)程序中用链表存放学生信息并实现增删减功能。
3、提示
(1)学生基本信息可以设计一个结构体类型
(2)自己构思并增加的除规定功能之外的新功能,酌情加分。*/
//--------------------------------------------------------------------------------------
int check(int n,char num[],char _code[]);
struct people *read_(); //从文件里读出结构体
void ban_p(); //将班级课表写入每个学生
void xiazai();
int ma_ten(); //退出
void last(); //结语
//--------------------------------------------------------------------------------------
void student_meu(); //学生界面
void st_one(char name[]); //学生修改信息
void st_one_one(char name[]); //
void st_two(char name[]); //选课信息
void st_two_three(); //学生信息录入
void st_three(char name[]); //考试成绩、重修
void st_four(char name[]); //修改密码
//--------------------------------------------------------------------------------------
void manage_meu(); //管理员界面.
void ma_one(); //管理员身份.
void ma_one_one(); //修改身份.
void ma_change(struct people *p0); //修改文件,存入一个单位.
voi
d ma_two(); //学院专业编码.
void ma_two_one(); //编排学院和专业.
void ma_two_two(); //查看学院和专业.
void ma_three(); //课程编码.
void ma_three_one(); //增加课程编排
void ma_three_two(); //查看课程
void ma_three_three(); //重新编排课程
void ma_four(); //选课信息.
void ma_five(); //学生信息管理.
void ma_five_one(); //学生信息查询.
void ma_five_two(); //学生身份修改.
void ma_five_four(); //学生成绩修改。
void ma_five_three(); //学生信息录入.
void ma_five_five(); //学生信息删除
void ma_six(); //统计管理
void ma_six_one(); //按班统计学生选课情况,考试成绩.
void ma_six_two(); //按课程统计学生名单及考试成绩.
void ma_six_three(); //统计并输出每个同学已修学分及不及三格课程).
void ma_six_four(); //录入班级选课.
//--------------------------------------------------------------------------------------
struct ban //班级
{
int one;//学院
int two;//专业
int three;//;班级
int four[30];//课表
double five[30];//各科平均分
struct ban *next;
};
//--------------------------------------------------------------------------------------
struct classes //课程结构体
{
int one;
char ch[50];
double sum;//该科目学分
};
//--------------------------------------------------------------------------------------
struct school //编码学院和专业
{
int one; // 学院编号
char two[20]; //学院名称
int three[20]; //专业编号
char four[20][100];//专业名称
struct school *next;
};
//--------------------------------------------------------------------------------------
struct people //学生的结构体
{
char st_num[20]; //学号
char name[20]; //姓名
char sex[20]; //性别
int age; //年龄
char dor_num[20]; //宿舍号码
char ph_num[20]; //电话号码
int sub_[20];
int kao[20]; //考试科目
double sub1[20]; //各科考试成绩
double sub2[20]; //各科平时成绩
double sub3[20]; //各科综合成绩
char code[20]; //用户密码
int sc_ta[50]; //个人课表
int sc_ro[50]; //课室
char _sc[20]; //就读学校
int _sub1; //学院,
int _sub2; //专业
int _cla; //班级
int _ji; //级数
float xuefen; //已修学分
struct people *next;
};
//--------------------------------------------------------------------------------------
struct classes* re1(int n)
//返回课程的结构体
{
FILE *fp;
struct classes *p;
fp=fopen("D:\\file\\classes.txt","r");
p=(struct classes*)malloc(CLA);
while(fread(p,CLA,1,fp)!=0)
{
if(n==p->one) break;
}
fclose(fp);
return (p);
}
//--------------------------------------------------------------------------------------
struct school* re2(int n) //返回学院编号的结构体
{
FILE *fp;
struct school *p;
fp=fopen("D:\\file\\school.txt","r");
p=(struct school*)malloc(SCH);
while(fread(p,SCH,1,fp)!=0)
{
if(n==p->one) break;
}
fclose(fp);
return (p);
}
//--------------------------------------------------------------------------------------
struct ban*read_2() //返回文件里班的结构体
{
FILE *fp;
n_n2=0;
fp=fopen("D:\\file\\ban.txt","r");
struct ban *head,*p1,*p2;
p1=(struct ban*)malloc(sizeof(struct ban));
while(fread(p1,sizeof(struct ban),1,fp)!=0)
{
if(n_n2==0) head=p1;else p2->next=p1;
p2=p1;
p1=(struct ban*)malloc(sizeof(struct ban));
n_n2++;
}
p2->next=NULL;
fclose(fp);
return(head);
}
//--------------------------------------------------------------------------------------
struct ban*re3(struct people *p0) //返回一个班的结构体
{
FILE *fp;
fp=fopen("D:\\file\\ban.txt","r");
struct ban *p;
p=(struct ban*)malloc(sizeof(struct ban));
while(fread(p,sizeof(struct ban),1,fp)!=0)
{
if(p->one==p0->_sub1&&p->two==p0->_sub2&&p->three==p0->_cla) break;
}
fclose(fp);
return (p);
}
//--------------------------------------------------------------------------------------
struct ban *average(struct ban*p0) //统计一个班各科的平均分
{
struct people *p1;
int i,j,n;
double sum[20]={0};
p1=read_();
j=0;
while(p1!=NULL)
{
i=0;
if(p0->one==p1->_sub1&&p0->two==p1->_sub2&&p0->three==p1->_cla)
{
while(p1->sc_ta[i]!=0)
{
sum[i]+=p1->sub1[i];
i++;
}
j++;
}
p1=p1->next;
}
n=i;
while(n>0)
{
sum[n-1]=sum[n-1]/j;
n--;
p0->five[n]=sum[n];
}
return (p0);
}
//--------------------------------------------------------------------------------------
void ma_change2(struct ban *p0) //修改文件里一个班级
{
FILE *fp;
struct ban *p;
int flag_1=0;
p=read_2();
fp=fopen("D:\\file\\ban.txt","w");
while(p!=NULL)
{
if(p->one==p0->one&&p->two==p0->two&&p->three==p0->three)
{
fwrite(p0,sizeof(struct ban),1,fp);
flag_1=1;
}
else
fwrite(p,sizeof(struct ban),1,fp);
p=p->next;
if(p==NULL) break;
n_n2--;
}
fclose(fp);
if(flag_1==0)
{
fp=fopen("D:\\file\\ban.txt","a"); //重写
fwrite(p0,sizeof(struct ban),1,fp);
fclose(fp);
}
}
//------------
--------------------------------------------------------------------------
struct people *read_() //读出文件里的结构体
{
FILE *fp;
n_n=0;
struct people *head,*p1,*p2;
fp=fopen("D:\\file\\a.txt","r");
p1=(struct people *)malloc(LEN);
while(fread(p1,LEN,1,fp)!=0)
{
if(n_n==0) head=p1;else p2->next=p1;
p2=p1;
n_n++;
p1=(struct people *)malloc(LEN);
}
p2->next=NULL;
fclose(fp);
return(head);
}
//--------------------------------------------------------------------------------------
void cut_people(struct people *p0) //删除一个单位
{
FILE *fp;
struct people *p;
p=read_();
fp=fopen("D:\\file\\a.txt","w");
while(n_n>0)
{
if(strcmp(p0->st_num,p->st_num)!=0)
fwrite(p,LEN,1,fp);
p=p->next;
n_n--;
}
fclose(fp);
}
//--------------------------------------------------------------------------------------
void ma_change(struct people *p0) //修改文件,存入一个单位
{
FILE *fp;
struct people *p;
int flag_1=0;
p=read_();
fp=fopen("D:\\file\\a.txt","w");
while(n_n>0)
{
if(strcmp(p0->st_num,p->st_num)==0)
{
fwrite(p0,LEN,1,fp);
flag_1=1;
}
else
fwrite(p,LEN,1,fp);
p=p->next;
n_n--;
}
fclose(fp);
if(flag_1==0)
{
fp=fopen("D:\\file\\a.txt","a"); //重写
fwrite(p0,LEN,1,fp);
fclose(fp);
}
}
//--------------------------------------------------------------------------------------
void ban_p() //将班级课表写入每个学生
{
FILE *fp1,*fp2;
struct ban *head1,*p1;
struct people *head2,*p2;
int i;
fp1=fopen("D:\\file\\ban.txt","r");
fp2=fopen("D:\\file\\a.txt","r");
p1=(struct ban*)malloc(sizeof(struct ban));
p2=(struct people*)malloc(LEN);
head2=p2=read_();
head1=p1=read_2();
while(p1!=NULL)
{
while(p2!=NULL)
{
if(p1->one==p2->_sub1&&p1->two==p2->_sub2&&p1->three==p2->_cla)
{i=0;
while(p1->four[i]!=0)
{
p2->sc_ta[i]=p1->four[i];
i++;
}
p2->sc_ta[i]=0;
}
p2=p2->next;
}
p1=p1->next;
}
fclose(fp1);
fclose(fp2);
fp2=fopen("D:\\file\\a.txt","w");
p2=head2;
while(p2!=NULL)
{
fwrite(p2,LEN,1,fp2);
p2=p2->next;
}
fclose(fp2);
}
//--------------------------------------------------------------------------------------
void Begining() //开始
{
char ch;
system("color 3e");
printf("当前日期:");
system("date/t");
printf("当前时间:");
system("time/t");
printf("\n\n\n\t\t\t\t************\n");
printf("\t\t\t\t| 欢迎进入 |\n");
printf("\t\t\t\t************\n");
printf("\n\n\n\t\t\t 华南农业大学教务管理系
统\n");
printf("\n\n \t\t||+||+||+||+||+||+||+||+||+||+||+||+||+||");
printf("\n\n\n\n\t\t请按enter继续........");
ch=getch();
}
//--------------------------------------------------------------------------------------
void iden() //不同身份的登陆
{
system("cls");
printf("当前日期:");
system("date/t");
printf("当前时间:");
system("time/t");
printf("\n\n\n\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆\n");
printf("\t\t◆ ◆\n");
printf("\t\t◆ ◆\n");
printf("\t\t◆ 1.管理员 ◆\n");
printf("\t\t◆ ◆\n");
printf("\t\t◆ ◆\n");
printf("\t\t◆ 2.学生 ◆\n");
printf("\t\t◆ ◆\n");
printf("\t\t◆ ◆\n");
printf("\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆\n\n\n");
printf("\t请选择您的登陆身份,按回车确定:");
}
//--------------------------------------------------------------------------------------
void getcode() //获得身份和密码
{
char ch1[100];
int i,flag=0,num=0;
ma_st=0;
while(1) //进入“管理员”
{
i=0;
while((ch1[i]=getch())!='\r') {putchar(ch1[i]);i++;}
if(i>1) ch1[0]='9';
if(ch1[0]=='1')
{
flag=0;
//printf("1");
printf(".管理员您好!\n\t请您输入您的密码,按回车结束:");
while(1)
{
i=0;
while((code[i]=getch())!='\r'&&i<16)
{
printf("*");i++;
}
code[i]='\0';
if(i>=16)
{system("cls");
iden();
printf("1.管理员您好!\n");
printf("\t对不起,您输入的密码有误,请重新输入:\n");
}
else if(check(1,0,code)==1)
{flag=1;ma_st=1;break;}
else
{system("cls");
iden();
printf("1.管理员您好!\n");
printf("\t对不起,您输入的密码有误,请重新输入:");
}
}
}
else if(ch1[0]=='2') //进入“学生”
{
flag=0;
printf("\n\n\t请您输入你的学号,按回车结束:");
while(1)
{
i=0;
while((name[i]=getchar())!='\n') i++;
name[i]='\0';
if(i>=13)
{
system("cls");
iden();
printf("2\n\n");
printf("\t对不起,您输入的学号有误,学号为12位的正数,请重新输入:");
}
else break;
}
printf("\t请输入您的密码,按回车结束:");
while(1)
{
i=0;
while((code[i]=getch())!='\r') {printf("*");i++;}
code[i]='\0';
if(i>=16)
{
system("cls");
iden
();
printf("2\n\n\t请您输入你的学号,按回车结束:\n%s\n",name);
}
else if(check(2,name,code)==2)
{flag=1;ma_st=2;break;}
else
{
system("cls");
iden();
printf("2\n\n\t请您输入你的学号,按回车结束:%s\n",name);
printf("\t对不起,您输入的密码有误,请重新输入:");
}
}
}
else //重新选择身份
{
system("cls");
iden();
printf("\n\t对不起,您的输入有误,输入应为1~2的数字,请重新选择您的身份:");
}
if(flag==1) break; //若身份和密码都已验证,退出循环,进入下一个函数
}
}
//--------------------------------------------------------------------------------------
int check(int n,char num[],char _code[]) //密码的验证
{
FILE *fp;
int i=0;
struct people s;
if((fp=fopen("D:\\file\\a.txt","r"))==NULL) exit(0);
if(n==1)
{
fread(&s,LEN,1,fp);
if(strcmp(_code,s.code)==0) i=1;
else i=0;
fclose(fp);
}
else if(n==2)
{
while(fread(&s,LEN,1,fp)!=0)
{
if(strcmp(num,s.st_num )==0) break;
}
if(strcmp(_code,s.code)==0) i=2;
else i=0;
fclose(fp);
}
return(i); //若返回1则是管理员,2则是学生
}
//--------------------------------------------------------------------------------------
void manage_meu() //管理员界面
{
char ch[100];
int i,flag_1=0,flag_2=0;
while(1)
{
system("cls");
printf("当前日期:");
system("date/t");
printf("当前时间:");
system("time/t");
printf("\n\t\t\t\t************\n");
printf(" \t+++++++++++++++++++++++| 管理员 |+++++++++++++++++++++++\n");
printf("\t|\t\t\t************\t\t\t |\n");
printf("\t|\t\t\t \t\t\t |\n");
printf("\t|\t\t\t<1>.修改身份\t\t\t |\n");
printf("\t|\t\t\t<2>.学生管理\t\t\t |\n");
printf("\t|\t\t\t<3>.统计管理\t\t\t |\n");
printf("\t|\t\t\t<4>.课程管理\t\t\t |\n");
printf("\t|\t\t\t<5>.修改密码\t\t\t |\n");
printf("\t|\t\t\t<6>.编排管理\t\t\t |\n");
printf("\t|\t\t\t<7>.返回上层\t\t\t |\n");
printf("\t|\t\t\t<0>.退出系统\t\t\t |\n");
printf(" \t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
printf("\t请选择功能,按回车确定:");
while(1)
{
i=0;
flag_1=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case'0':flag_2=ma_ten();break;
case'1':ma_one();break;
case'2':ma_five();break;
case'3':ma_six();break;
case'4':ma_three();break;
case'5':st_four("0000");break;
case'6':ma_two();break;
case'7':flag_2=1;break;
default:{printf("\t您的输入有误,请重新输入:");flag_1=1;}
}
if(flag_1==0) break;
}
if(flag_2==1) break;
}
}
//-------------------------------------------------------------------------------
-------
void student_meu() //学生界面.
{
char ch[100];
int i,flag_1=0,flag_2=0;
while(1)
{
system("cls");
printf("当前日期:");
system("date/t");
printf("当前时间:");
system("time/t");
printf("\n\t\t\t\t************\n");
printf(" \t+++++++++++++++++++++++| 学生 |+++++++++++++++++++++++\n");
printf("\t|\t\t\t************\t\t\t |\n");
printf("\t|\t\t\t \t\t\t |\n");
printf("\t|\t\t\t<1>.修改身份\t\t\t |\n");
printf("\t|\t\t\t<2>.选课信息\t\t\t |\n");
printf("\t|\t\t\t<3>.考试成绩\t\t\t |\n");
printf("\t|\t\t\t<4>.修改密码\t\t\t |\n");
printf("\t|\t\t\t<5>.返回上层\t\t\t |\n");
printf("\t|\t\t\t<0>.退出系统\t\t\t |\n");
printf(" \t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
printf("\t请选择功能,按回车确定:");
while(1)
{
i=0;
flag_1=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case'0':flag_2=ma_ten();break;
case'1':st_one(name);break;
case'2':st_two(name);break;
case'3':st_three(name);break;
case'4':st_four(name);break;
case'5':flag_2=1;break;
default:{printf("\t您的输入有误,请重新输入:\n");flag_1=1;}
}
if(flag_1==0) break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_one_one() //修改管理员的身份
{
FILE *fp;
fp=fopen("D:\\file\\a.txt","r");
struct people s;
int flag_1=0,flag_2=0,flag_3=0;
char ch[100];
int i=0,n=0;
while(fread(&s,LEN,1,fp)!=0)
{
if(strcmp(s.st_num ,"0000")==0)
break;
}
fclose(fp);
i=0;
while(1)
{
system("cls");
int i=0;
flag_2=0;
printf("\n您的身份:管理员\n\n");
printf("========================================================\n\n");
printf("请您输入您的姓名,按回车键结束:");
scanf("%s",&);
printf("--------------------------------------------------------\n");
printf("请您输入您的性别,按回车键结束:");
scanf("%s",&s.sex);
printf("--------------------------------------------------------\n");
printf("请您输入您的年龄,按回车键结束:");
scanf("%d",&s.age);
printf("--------------------------------------------------------\n");
printf("请您输入您的电话号码,按回车键结束:");
scanf("%s",&s.ph_num);
strcpy(s.st_num ,"0000");
ch[0]=getchar();
printf("========================================================\n\n");
printf(" ----------------------------------------\n");
printf(" | 1.确认\t2.重新输入\t3.返回 |\n");
printf(" ----------------------------------------\n");
printf("请您选择:");
while(1)
{
i=0;
flag_3
=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[i-1]='4';
switch(ch[i-1])
{
case '1':
{
ma_change(&s);
printf("数据已经保存,按enter继续--------------");
ch[0]=getchar();
flag_1=1;
break;
}
case '2':flag_2=1;break;
case '3':flag_1=1;break;
default:flag_3=1;
}
if(flag_3==1) printf("您的输入有误,请输入1~3:");
else break;
}
if(flag_1==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_one() //管理员身份.
{
while(1)
{
struct people s;
int flag_1=0,flag_2=0;
char ch[20];
int i;
FILE *fp;
fp=fopen("D:\\file\\a.txt","r");
while(fread(&s,LEN,1,fp)!=0)
{
if(strcmp(s.st_num,"0000")==0) break;
}
system("cls");
{
printf("\n");
printf("\t你的身份:管理员\n");
printf(" ----------------------------------------\n");
printf(" | 姓名:%s \n |\t\t\t\t\t |\n",);
printf(" | 姓别:%s \n |\t\t\t\t\t |\n",s.sex);
printf(" | 年龄:%2d\n |\t\t\t\t\t |\n",s.age);
printf(" | 电话号码:%s \n |\t\t\t\t\t |\n",s.ph_num);
printf(" ----------------------------------------\n\n");
}
fclose(fp);
printf(" ----------------------------------------\n");
printf(" | <1>.修改信息\t <2>.返回 |\n");
printf(" ----------------------------------------\n");
printf(" 请您选择:");
while(1)
{ i=0;
flag_2=0;
while((ch[i]=getchar())!='\n') i++;
if(i>=2) ch[i-1]='3';
switch(ch[i-1])
{
case '1': ma_one_one();break;
case '2':flag_1=1;break;
default:{flag_2=1;}
}
if(flag_2==1) printf(" 你的输入有误,请输入1~2:");
else break;
}
if(flag_1==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_five() //学生信息管理。
{
char ch[100];
int i,flag_1=0,flag_2=0;
while(1)
{
system("cls");
printf("\n\n\n\t\t\t\t 欢迎进入\n");
printf("\t\t\t\t************\n");
printf(" \t+++++++++++++++++++++++| 学生管理 |+++++++++++++++++++++++\n");
printf("\t|\t\t\t************\t\t\t |\n");
printf("\t|\t\t <1>. 学生信息查询\t\t\t |\n");
printf("\t|\t\t <2>. 学生身份修改\t\t\t |\n");
printf("\t|\t\t <3>. 学生成绩修改\t\t\t |\n");
printf("\t|\t\t <4>. 学生信息录入\t\t\t |\n");
printf("\t|\t\t <5>. 学生信息删除\t\t\t |\n");
printf("\t|\t\t <0>. 返回上层 \t\t\t |\n");
printf(" \t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n");
printf("\t请选择功能,按回车确定:");
w
hile(1)
{
i=0;
flag_1=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case'1':ma_five_one();break;
case'2':ma_five_two();break;
case'3':ma_five_four();break;
case'4':ma_five_three();break;
case'5':ma_five_five();break;
case'0':flag_2=1;break;
default:{printf("\t您的输入有误,请输入正确选项:");flag_1=1;}
}
if(flag_1==0) break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_five_four() //学生成绩修改
{
FILE *fp;
FILE *fp1;
FILE *fp2;
fp1=fopen("D:\\file\\classes.txt","r");
struct people *p1,*p2;
struct classes *p3;
struct school *head,*p;
int ch[100];
int i=0,j=0;
int flag_1=0,flag_2=0,flag_3=0;
p1=(struct people*)malloc(LEN);
system("cls");
printf("\n\t\t欢迎进入 学生成绩修改 界面\n");
printf("========================================================\n");
printf("请输入要修改的学生的学号,按回车结束:"); //
while(1)
{
flag_1=0;
flag_3=0;
scanf("%s",&p1->st_num); ch[0]=getchar();
fp=fopen("D:\\file\\a.txt","r");
p2=(struct people*)malloc(LEN);
while(fread(p2,LEN,1,fp)!=0)
{
if(strcmp(p1->st_num ,p2->st_num)==0)
{flag_3=1;break;}
}
if(flag_3==0) {printf("输入的学号不存在,");continue;}
system("cls");
printf("\n\t\t欢迎进入 学生成绩修改界面\n");
printf("========================================================\n");
printf(" --------- 原学生资料 ---------\n");
printf("--------------------------------------------------------\n\n");
printf("学生学号:%s\n",p2->st_num);
printf("学生姓名:%s\n",p2->name);
printf("就读学校:%s\n",p2->_sc);
p=re2(p2->_sub1);
printf("学院:%s\n",p->two);
printf("专业:%s\n",p->four[p2->_sub2]);
printf("班级:%d班\n",p2->_cla );
printf("--------------------------------------------------------\n");
printf("课程:\n" );
printf("--------------------------------------------------------\n");
i=0;
p3=(struct classes*)malloc(CLA);
while(p2->sc_ta[i]!=0)
{
p3=re1(i);
printf("%-10s",p3->ch);i++;
if(i%4==0) printf("\n");
}
printf("\n--------------------------------------------------------\n\n");
printf("请输入学生学校,按回车结束:");
scanf("%s",&p2->_sc); ch[0]=getchar();
printf("\n--------------------------------------------------------\n");
head=p=(struct school *)malloc(SCH);
fp2=fopen("D:\\file\\school.txt","r");
j=0;
while(fread(p,SCH,1,fp2)!=0)
{
printf("%2d:%-20s",p->one,p->two);
j++;
if(j%3==0) putchar('\n');
}
printf("\n--------------------------------------------------------\n");
printf("请选择学院的编号,如01,按回车确定:"
);
scanf("%d",&p2->_sub1); ch[0]=getchar();
printf("--------------------------------------------------------\n");
rewind(fp2);
while(fread(p,SCH,1,fp2)!=0)
{
if(p->one ==p2->_sub1 ) break;
}
j=0;
while(p->three[j]!=0)
{
printf("%d:%-20s",p->three[j] ,p->four[j] );j++;
if(j%2==0) putchar('\n');
}
fclose(fp2);
printf("\n--------------------------------------------------------\n");
printf("请选择专业的编码,按回车确定:");
scanf("%d",&p2->_sub2); ch[0]=getchar();
printf("请输入学生班级,按回车结束:");
scanf("%d",&p2->_cla); ch[0]=getchar();
printf("\n--------------------------------------------------------\n");
fp2=fopen("D:\\file\\classes.txt","r");
p3=(struct classes*)malloc(CLA);
j=0;
while(fread(p3,CLA,1,fp2)!=0)
{
printf("%2d:%-10s",p3->one,p3->ch);j++;
if(j%4==0) putchar('\n');
}
fclose(fp2);
printf("\n--------------------------------------------------------\n");
printf("请输入学生课程的编码,当输入00时表示结束\n");
printf("\n--------------------------------------------------------\n");
i=0;
do
{
printf("第%d门课程:",i+1);
scanf("%d",&p2->sc_ta[i]);ch[0]=getchar();
if(p2->sc_ta[i]==0) break;
printf("请输入该课程的考试成绩:");
scanf("%llf",&p2->sub1[i]);ch[0]=getchar();
printf("请输入该课程的平时成绩:");
scanf("%llf",&p2->sub2[i]);ch[0]=getchar();
i++;
}while(p2->sc_ta[i-1]!=0);
printf("1.确认\t\t2.重新修改\t\t3.返回\n");
while(1)
{
int i=0;
flag_2=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1' :flag_1=1;break;
case '2' :system("cls");break;
case '3' :flag_1=2;break;
default:{printf("您的输入有误,请重新选择:");flag_2=1;}
}
if(flag_2==0) break;
}
if(flag_1==1)
{
ma_change(p2);
printf("学生信息已经保存,请按回车继续-------------");
ch[0]=getchar();
break;
}
else if(flag_1==2) break;
}
}
//--------------------------------------------------------------------------------------
void ma_five_one() //学生信息查询
{
struct people *p1,*p2;
struct school *p;
struct classes *p3;
FILE *fp;
char ch;
int flag_1=0;
int i=0;
p1=(struct people*)malloc(LEN);
p2=(struct people*)malloc(LEN);
system("cls");
printf("\n\t\t欢迎进入 学生信息查询 界面\n");
printf("========================================================\n");
printf("请输入要查询的学生的学号,按回车结束:");
while(1)
{
scanf("%s",&p1->st_num);
if((fp=fopen("D:\\file\\a.txt","r"))==NULL)
{printf("你的文件有误\n");fclose(fp);}
while(fread(p2,LEN,1,fp)!=0)
{
if(strcmp(p1->st_num ,p2->st_num)==0)
{flag_1=1;break;}
}
i
f(flag_1==1) break;
else printf("该学号不存在,请重新输入:");
}
system("cls");
printf("\n\t\t欢迎进入 学生信息查询 界面\n");
printf("========================================================\n");
printf(" --------- 学生基本信息 ---------\n");
printf("--------------------------------------------------------\n\n");
printf(" 学号:%-20s",p2->st_num );
printf("姓名:%-20s\n",p2->name );
printf(" 性别:%-20s",p2->sex );
printf("年龄:%d\n",p2->age );
printf("宿舍号码:%-20s",p2->dor_num );
printf("电话号码:%s\n",p2->ph_num );
printf(" 密码:%s\n",p2->code );
printf("========================================================\n");
printf(" --------- 学生课程信息 ---------\n");
printf("--------------------------------------------------------\n\n");
p=re2(p2->_sub1);
printf(" 学校:%-20s",p2->_sc);
printf("学院:%s\n",p->two);
printf(" 专业:%-20s",p->four[p2->_sub2]);
printf("班级:%d班\n",p2->_cla );
printf("--------------------------------------------------------\n");
printf("课程及分数:\n" );
printf("--------------------------------------------------------\n");
printf("- 课程 ------------ 考试成绩 ----------- 平时成绩 ------\n");
i=0;
p3=(struct classes*)malloc(CLA);
while(p2->sc_ta[i]!=0)
{
p3=re1(i);
printf("%2d:%-10s %-2.1llf %-2.1llf\n",i+1,p3->ch,p2->sub1[i],p2->sub2[i]);
i++;
}
printf("--------------------------------------------------------\n\n");
printf("按回车键继续---------");
ch=getchar();
ch=getchar();
fclose(fp);
}
//--------------------------------------------------------------------------------------
void ma_five_two() //学生身份修改.
{
FILE *fp;
struct people *p1,*p2;
int ch[100];
int i=0;
int flag_1=0,flag_2=0,flag_3=0;
p1=(struct people*)malloc(LEN);
system("cls");
printf("\n\t\t欢迎进入 学生身份修改 界面\n");
printf("========================================================\n");
while(1)
{
flag_1=0;
flag_3=0;
printf("请输入要修改的学生的学号,按回车结束:"); //
scanf("%s",&p1->st_num); ch[0]=getchar();
fp=fopen("D:\\file\\a.txt","r");
p2=(struct people*)malloc(LEN);
while(fread(p2,LEN,1,fp)!=0)
{
if(strcmp(p1->st_num ,p2->st_num)==0)
{flag_3=1;break;}
}
if(flag_3==0) {printf("该学号不存在,");continue;}
printf("--------------------------------------------------------\n");
printf("---------------- 该学生原资料 ------------------\n");
printf(" 姓名:%s\n",p2->name );
printf(" 性别:%s\n",p2->sex );
printf(" 年龄:%d\n",p2->age );
printf(" 密码:%s\n",p2->code );
printf(" 宿舍号码:%s\n",p2->dor_num
);
printf(" 电话号码:%s\n\n",p2->ph_num );
printf("--------------------------------------------------------\n");
printf("---------------- 资料修改 ------------------\n");
printf("请输入学生姓名,按回车结束:");
scanf("%s",&p2->name); ch[0]=getchar();
printf("请输入学生性别,按回车结束:");
scanf("%s",&p2->sex); ch[0]=getchar();
printf("请输入学生年龄,按回车结束:");
scanf("%d",&p2->age); ch[0]=getchar();
printf("请输入学生宿舍号码,按回车结束:");
scanf("%s",&p2->dor_num); ch[0]=getchar();
printf("请输入学生电话号码,按回车结束:");
scanf("%s",&p2->ph_num); ch[0]=getchar();
printf("请输入学生帐户密码,按回车结束:");
scanf("%s",&p2->code); ch[0]=getchar();
printf("========================================================\n");
printf("\t1.确认\t\t2.重新修改\t\t3.返回\n");
printf("请选择,按回车确定:");
while(1)
{
int i=0;
flag_2=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1' :flag_1=1;break;
case '2' :system("cls");break;
case '3' :flag_1=2;break;
default:{printf("输入有误,请重新选择:\n");flag_2=1;}
}
if(flag_2==0) break;
}
if(flag_1==1)
{
ma_change(p2);
printf("学生信息已经保存,请按回车继续-------------");
ch[0]=getchar();
break;
}
else if(flag_1==2) break;
}
}
//---------------------------------------------------------------------------------------------
void ma_five_three() //学生信息录入
{
FILE *fp,*fp2;
struct people *p1,*p2;
struct school *head,*p;
struct classes *p4;
struct ban *p3;
int ch[100];
int i=0,j=0;
int flag_1=0,flag_2=0,flag_3=0;
p1=(struct people*)malloc(LEN);
system("cls");
printf("\n\t\t欢迎进入 学生信息录入 界面\n");
printf("========================================================\n\n");
printf("请输入要录入的学生的学号,按回车结束:");
while(1)
{
flag_1=0;
flag_3=0;
scanf("%s",&p1->st_num); ch[0]=getchar();
fp=fopen("D:\\file\\a.txt","r");
p2=(struct people*)malloc(LEN);
while(fread(p2,LEN,1,fp)!=0)
{
if(strcmp(p1->st_num ,p2->st_num)==0)
{flag_3=1;break;}
}
if(flag_3==1) {printf("该学号已存在,请输入新的学号:");continue;}
printf("--------------------------------------------------------\n");
putchar('\n');
printf("请输入学生的姓名,按回车结束:");
scanf("%s",&p1->name); ch[0]=getchar();putchar('\n');
printf("请输入学生的性别,按回车结束:");
scanf("%s",&p1->sex); ch[0]=getchar();putchar('\n');
printf("请输入学生的年龄,按回车结束:");
scanf("%d",&p1->age); ch[0]=getchar();putchar('\n');
p
rintf("请输入学生的宿舍号码,按回车结束:");
scanf("%s",&p1->dor_num); ch[0]=getchar();putchar('\n');
printf("请输入学生的电话号码,按回车结束:");
scanf("%s",&p1->ph_num); ch[0]=getchar();putchar('\n');
printf("请输入学生学校,按回车结束:");
scanf("%s",&p1->_sc); ch[0]=getchar();putchar('\n');
printf("\n--------------------------------------------------------\n");
head=p=(struct school *)malloc(SCH);
fp2=fopen("D:\\file\\school.txt","r");
j=0;
while(fread(p,SCH,1,fp2)!=0)
{
printf("%2d:%-20s",p->one,p->two);
j++;
if(j%3==0) putchar('\n');
}
printf("\n--------------------------------------------------------\n");
printf("请选择学院的编号,如01,按回车确定:");
scanf("%d",&p1->_sub1); ch[0]=getchar();
printf("--------------------------------------------------------\n");
rewind(fp2);
while(fread(p,SCH,1,fp2)!=0)
{
if(p->one ==p1->_sub1 ) break;
}
j=0;
while(p->three[j]!=0)
{
printf("%d:%-20s",p->three[j] ,p->four[j] );j++;
if(j%2==0) putchar('\n');
}
fclose(fp2);
printf("\n--------------------------------------------------------\n");
printf("请选择专业的编码,按回车确定:");
scanf("%d",&p1->_sub2); ch[0]=getchar();
printf("请输入学生班级,按回车结束:");
scanf("%d",&p1->_cla); ch[0]=getchar();
p3=re3(p1);
p4=(struct classes*)malloc(CLA);
j=0;
while(p3->four[j]!=0)
{
printf("第%d门课程:",j+1);
p4=re1(p3->four[j]);
p1->sc_ta[j]=p3->four[j];
printf("%s\n",p4->ch);
printf("请输入该门课程的考试成绩:");
scanf("%llf",&p1->sub1[j]);ch[0]=getchar();
printf("请输入该门课程的平时成绩:");
scanf("%llf",&p1->sub2[j]);ch[0]=getchar();
j++;
}
p1->sc_ta[j]=0;
printf("学生的原始密码与账号一致。\n");
strcpy(p1->code,p1->st_num );
printf("========================================================\n\n");
printf("1.确认\t\t2.重新录入\t\t3.返回\n");
printf("请选择,按回车确定:");
while(1)
{
int i=0;
flag_2=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1' :flag_1=1;break;
case '2' :system("cls");break;
case '3' :flag_1=2;break;
default:{printf("您的输入有误,请重新选择:");flag_2=1;}
}
if(flag_2==0) break;
}
if(flag_1==1)
{
fp=fopen("D:\\file\\a.txt","a");fwrite(p1,LEN,1,fp);
fclose(fp);
printf("操作成功!学生信息已保存,请按回车继续-------------");
ch[0]=getchar();
break;
}
else if(flag_1==2) break;
}
}
//--------------------------------------------------------------------------------------
void ma_five_five() //学生信息删除
{
FILE
*fp;
struct people *p1,*p2;
int ch[100];
int i=0;
int flag_1=0,flag_2=0,flag_3=0;
p1=(struct people*)malloc(LEN);
system("cls");
printf("\n\t\t欢迎进入 学生信息删除 界面\n");
printf("========================================================\n");
printf("请输入要删除的学生的学号,按回车结束:"); //
while(1)
{
flag_1=0;
flag_3=0;
scanf("%s",&p1->st_num); ch[0]=getchar();
fp=fopen("D:\\file\\a.txt","r");
p2=(struct people*)malloc(LEN);
while(fread(p2,LEN,1,fp)!=0)
{
if(strcmp(p1->st_num ,p2->st_num)==0)
{flag_3=1;break;}
}
if(flag_3==0) {printf("输入的学号不存在,请重新输入:");continue;}
system("cls");
printf("\n\t\t欢迎进入 学生信息删除 界面\n");
printf("========================================================\n");
printf("---------------- 学生 资料 ------------------\n");
printf("--------------------------------------------------------\n");
printf("学号:%s\n\n",p2->st_num );
printf("姓名:%s\n\n",p2->name );
printf("性别:%s\n\n",p2->sex );
printf("年龄:%d\n\n",p2->age );
printf("宿舍号码:%s\n\n",p2->dor_num );
printf("电话号码:%s\n\n",p2->ph_num );
printf("密码:%s\n",p2->code );
printf("========================================================\n\n");
printf("\t1.确认删除\t\t2.返回\n\n");
printf("请选择,按回车确定:");
while(1)
{
int i=0;
flag_2=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1' :flag_1=1;break;
case '2' :flag_1=2;break;
default:{printf("您的输入有误,请重新选择:");flag_2=1;}
}
if(flag_2==0) break;
}
if(flag_1==1)
{
cut_people(p2);
printf("操作成功!学生信息已删除,请按回车继续-------------");
ch[0]=getchar();
break;
}
else if(flag_1==2) break;
}
}
//--------------------------------------------------------------------------------------
void ma_two() //学院专业编码
{
char ch[100];
int i,flag_1=0,flag_2=0;
system("cls");
printf("\n\n\n\t\t\t\t 欢迎进入\n");
printf("\t\t\t\t************\n");
printf(" \t+++++++++++++++++++++++| 学生管理 |+++++++++++++++++++++++\n");
printf("\t|\t\t\t************\t\t\t |\n");
printf("\t|\t\t <1>. 编排学院及专业号码\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf("\t|\t\t <2>. 查看学院及专业编码\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf("\t|\t\t <0>. 返回上一界面\t\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf(" \t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n");
printf("请选择功能,按回车确
定:");
while(1)
{
while(1)
{
i=0;
flag_1=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':ma_two_one();break;
case '2':ma_two_two();break;
case '0':flag_2=1;break;
default:{printf("您的输入有误,请重新输入:");flag_1=1;}
}
if(flag_1==0) break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_two_one() //编排学院和专业
{
struct school *p,*p2;
FILE *fp;
int flag_1=0,flag_2=0,flag_3=0,flag_4=0;
int i=0,j=0;
char ch[100];
system("cls");
printf("请录入编号以及对应的学院和专业\n");
printf("------------------------------------------------------------\n");
printf("温馨提示:编号由4位数字组成,前两位代表学院,后两位代表专业,\n如 0101: 信息学院,软件工程\n");
printf("------------------------------------------------------------\n\n");
printf("请写入学院编号数字,如 01,按回车确定:");
while(1)
{
j=0;
flag_1=0;flag_2=0,flag_4=0;
p=(struct school *)malloc(SCH);
scanf("%d",&p->one );
fp=fopen("D:\\file\\school.txt","r"); //
p2=(struct school*)malloc(SCH);
while(fread(p2,SCH,1,fp)!=0)
{
if(p->one==p2->one)
{flag_4=1;break;}
}
if(flag_4==1) {printf("对不起,该学院编号已存在,请重新输入:");fclose(fp);continue;}
printf("请您写入该编号代表的学院,按回车确定:");
scanf("%s",&p->two );
printf("------------------------------------------------------------\n");
printf("|请输入该学院专业编号,当输入的专业编号为 00时表示输入结束!|\n");
printf("------------------------------------------------------------\n\n");
do
{
printf("请写入专业编号数字,如 01,按回车确定:");
scanf("%d",&p->three[j] );
if(p->three[j]==0 ) break;
printf("请您写入该编号代表的专业,按回车确定:");
scanf("%s",&p->four[j] );
ch[0]=getchar();
j++;
}while(p->three[j-1]!=0);
ch[0]=getchar();
printf("------------------------------------------------------------\n\n");
printf("\t\t1.确认\t2.返回\n");
printf("请选择:");
while(1)
{
i=0;flag_3=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':flag_1=1;break;
case '2':flag_2=1;break;
default:{printf("输入有误 ,请重新输入:");flag_3=1;}
}
if(flag_3==0) break;
}
if(flag_1==1)
{
fp=fopen("D:\\file\\school.txt","a");
fwrite(p,SCH,1,fp);
fclose(fp);
printf("该组编号已录入,请按任意键继续--------\n");
ch[20]=getchar();
break;
}
if(flag_2==1) break;
}
}
//---------------------------------------------------------------------------
-----------
void ma_two_two() //查看编排的学院和专业
{
FILE *fp;
struct school *p;
char ch;
int i;
fp=fopen("D:\\file\\school.txt","r");
p=(struct school*)malloc(SCH);
system("cls");
printf("\n\t\t学院和专业编排查看\n");
printf("========================================================\n");
while(fread(p,SCH,1,fp)!=0)
{
i=0;
if(p->one>9) printf("学院 %d:",p->one);
else printf("学院 0%d:",p->one);
printf("%-20s\n",p->two);
printf("--------\n专业 ");
while(p->three[i]!=0)
{
if(p->three[i]>9)
printf("%d :",p->three[i]);
else printf("0%d:",p->three[i]);
printf("%-20s",p->four[i]);
i++;
if(i%3==0)
{
if(p->three[i]!=0)
printf("\n ");
else printf("\n");
}
if(p->three[i]==0&&i%3!=0) putchar('\n');
}
printf("------------------------------------------------------------------------\n");
}
printf("按任意键返回-------------");
ch=getchar();
}
//--------------------------------------------------------------------------------------
void ma_three() //课程编码
{
char ch[100];
int i,flag_1=0,flag_2=0;
while(1)
{
system("cls");
printf("\n\n\n\t\t\t\t 欢迎进入\n");
printf("\t\t\t\t************\n");
printf(" \t+++++++++++++++++++++++| 课程管理 |+++++++++++++++++++++++\n");
printf("\t|\t\t\t************\t\t\t |\n");
printf("\t|\t\t <1>. 增加课程编排\t\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf("\t|\t\t <2>. 查看课程编码\t\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf("\t|\t\t <3>. 重新编排课程\t\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf("\t|\t\t <0>. 返回上一界面\t\t\t |\n");
printf("\t|\t\t \t\t |\n");
printf(" \t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n");
printf("请选择功能,按回车确定:");
while(1)
{
i=0;
flag_1=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':ma_three_one();break;
case '2':ma_three_two();break;
case '3':ma_three_three();break;
case '0':flag_2=1;break;
default:{printf("您的输入有误,请重新输入:");flag_1=1;}
}
if(flag_1==0) break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_three_three() //重新编排课程
{
struct classes *p;
FILE *fp;
int flag_1=0,flag_2=0,flag_3=0;
int i=0;
char ch[100];
system("cls");
printf("请录入编号以及对应的学科\n");
printf("----------------------------------------------------------
--\n");
printf("温馨提示:编号由3位数字组成,如 001:高等数学\n");
printf("------------------------------------------------------------\n\n");
printf("请写入学科编号数字,如 001,按回车确定:");
while(1)
{
flag_1=0;flag_2=0;
p=(struct classes *)malloc(CLA);
scanf("%d",&p->one );ch[0]=getchar();
printf("请写入该编号代表的学科, 按回车确定:");
scanf("%s",&p->ch );ch[0]=getchar();
printf("请写入修完该学科的学分, 按回车确定:");
scanf("%llf",&p->sum );
ch[0]=getchar();
printf("------------------------------------------------------------\n");
printf("\t\t1.确定\t\t2.返回\n");
while(1)
{
i=0;flag_3=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':flag_1=1;break;
case '2':flag_2=1;break;
default:{printf("输入有误 ,请重新输入:\n");flag_3=1;}
}
if(flag_3==0) break;
}
if(flag_1==1)
{
fp=fopen("D:\\file\\classes.txt","w");
fwrite(p,CLA,1,fp);
fclose(fp);
printf("操作成功!该编号已录入,请按任意键继续--------\n");
ch[20]=getchar();
break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_three_one() //增加课程编排
{
struct classes *p,*p2;
FILE *fp;
int flag_1=0,flag_2=0,flag_3=0,flag_4=0;
int i=0;
char ch[100];
system("cls");
printf("请录入编号以及对应的学科\n");
printf("------------------------------------------------------------\n");
printf("温馨提示:编号由3位数字组成,如 001:高等数学\n");
printf("------------------------------------------------------------\n\n");
printf("请写入学科编号数字,如 001,按回车确定:");
while(1)
{
flag_1=0;flag_2=0,flag_4=0;
p=(struct classes *)malloc(CLA);
scanf("%d",&p->one );
fp=fopen("D:\\file\\classes.txt","r");
p2=(struct classes*)malloc(CLA);
while(fread(p2,CLA,1,fp)!=0)
{
if(p->one==p2->one)
{flag_4=1;break;}
}
if(flag_4==1) {printf("你输入的学科编号已经存在,请重新输入:");fclose(fp);continue;}
printf("请写入该编号代表的学科,按回车确定:");
scanf("%s",&p->ch );ch[0]=getchar();
printf("请写入修完该学科的学分,按回车确定:");
scanf("%llf",&p->sum );
ch[0]=getchar();
printf("------------------------------------------------------------\n\n");
printf("\t1.确定\t2.返回\n");
while(1)
{
i=0;flag_3=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':flag_1=1;break;
case '2':flag_2=1;break;
default:{printf("输入有误 ,请重新输入:\n");flag_3=1;}
}
if(
flag_3==0) break;
}
if(flag_1==1)
{
fp=fopen("D:\\file\\classes.txt","a");
fwrite(p,CLA,1,fp);
fclose(fp);
printf("该编号已录入,请按任意键继续--------\n");
ch[20]=getchar();
break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_three_two() //查看课程
{
FILE *fp;
struct classes *p;
char ch;
fp=fopen("D:\\file\\classes.txt","r");
p=(struct classes*)malloc(CLA);
system("cls");
printf("\n\t\t课程编排查看\n");
printf("========================================================\n");
printf(" 编码: 课程: 学分 \n");
printf("------------------------------------------------------------------------\n");
while(fread(p,CLA,1,fp)!=0)
{
printf(" %3d: %-20s %-6.1llf \n",p->one,p->ch,p->sum);
}
printf("------------------------------------------------------------------------\n");
printf("按任意键返回-------------");
ch=getchar();
}
//--------------------------------------------------------------------------------------
void ma_six_one() //按班统计学生选课情况,考试成绩
{
struct school *p,*head;
struct classes *p2;
struct ban *p3;
FILE *fp1;
FILE *fp2;
int flag_1=0,flag_2=0,flag_3=0;
int i=0,j=0,n1,n2,n3;
char ch[100];
system("cls");
printf("\n\t\t按班统计学生选课\n");
printf("========================================================\n");
printf("\t温馨提示:请依次选择学院,专业,以及班级!\n");
printf("------------------------------------------------------------\n");
while(1)
{
j=0;
flag_1=0;flag_2=0;
head=p=(struct school *)malloc(SCH);
fp1=fopen("D:\\file\\school.txt","r");
while(fread(p,SCH,1,fp1)!=0)
{
printf("%2d:%-20s",p->one,p->two);j++;
if(j%2==0) printf("\n");
}
printf("\n------------------------------------------------------------\n");
printf("请选择学院的编号,如01,按回车确定:");
scanf("%d",&n1);
ch[0]=getchar();
printf("------------------------------------------------------------\n");
rewind(fp1);
while(fread(p,SCH,1,fp1)!=0)
{
if(p->one ==n1) break;
}
j=0;
while(p->three[j]!=0)
{
printf("%2d:%-10s",p->three[j] ,p->four[j] );j++;
if(j%3==0) printf("\n");
}
fclose(fp1);
printf("\n------------------------------------------------------------\n");
printf("请选择专业的编码,按回车确定:");
scanf("%d",&n2 );
printf("------------------------------------------------------------\n");
printf("请选择班级:");
scanf("%d",&n3);
ch[0]=getchar();
printf("1.确认\t2.返回\n");
while(1)
{
i=0;flag_3=0;
while((ch[i]=getchar(
))!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':flag_1=1;break;
case '2':flag_2=1;break;
default:{printf("输入有误 ,请重新输入:\n");flag_3=1;}
}
if(flag_3==0) break;
}
if(flag_1==1)
{
system("cls");
printf("\n\t\t该班选课情况及考试成绩\n");
printf("========================================================\n\n");
printf(" 课程 平均分\n");
fp2=fopen("D:\\file\\ban.txt","r");
p3=(struct ban*)malloc(sizeof(struct ban));
while(fread(p3,sizeof(struct ban),1,fp2)!=0)
{
if(p3->one==n1&&p3->two==n2&&p3->three==n3) break;
}fclose(fp2);
j=0;
p3=average(p3);
while(p3->four[j]!=0)
{
p2=re1(p3->four[j] );
j++;
printf("课程%2d:%-20s %.1llf\n\n",j,p2->ch,p3->five[j-1]);
}
printf("========================================================\n\n");
printf("请按任意键继续--------");
ch[20]=getchar();
break;
}
if(flag_2==1) break;
}
}
//--------------------------------------------------------------------------------------
void ma_six_two() //按课程统计学生名单及考试成绩,
{
system("cls");
FILE *fp;
struct classes *p;
struct people *p1;
int n,i,flag_1=0;
char ch;
fp=fopen("D:\\file\\classes.txt","r");
p=(struct classes*)malloc(CLA);
printf("\n\t\t按课程统计学生名单及考试成绩\n");
printf("========================================================\n");
i=0;
while(fread(p,CLA,1,fp)!=0)
{
if(p->one!=0)
printf("%d:%-10s",p->one,p->ch);
else break;
i++;
if(i%4==0) printf("\n");
}
fclose(fp);
printf("\n--------------------------------------------------------\n");
printf("请您输入您要查询的课程:");
scanf("%d",&n);
p=re1(n);
printf("%s\n",p->ch);
printf("\n--------------------------------------------------------\n");
printf(" 姓名: 学号: 考试成绩: 平时成绩\n");
fp=fopen("D:\\file\\a.txt","r");
p1=(struct people*)malloc(LEN);
while(fread(p1,LEN,1,fp)!=0)
{
i=0;flag_1=0;
while(p1->sc_ta[i]!=n)
{
if(p1->sc_ta[i]==0) {flag_1=0;break;}
i++;
}
if(flag_1==0) printf("%s: %s %.1llf %.1llf \n",p1->name,p1->st_num,p1->sub1[i],p1->sub2[i] );
}
fclose(fp);
printf("按enter返回-----------");
ch=getchar();
ch=getchar();
}
//--------------------------------------------------------------------------------------
void ma_six_three() //统计并输出每个同学已修学分与不及格课程
{
system("cls");
int i=1;
char ch;
struct people *p;
p=read_();
printf("\n\t\t学生名单及考试成绩\n");
printf("========================================================\n");
while(p!=NULL)
{
printf("%-10s: %-20s\n",p->name,p->st_num);
if((i%10)==0)
{
printf("请按回车键翻到下一页--------------");
ch=getchar();
system("cls");
}
p=p->next;
i++;
}
printf("请按回车键返回--------------");
ch=getchar();
}
//--------------------------------------------------------------------------------------
void ma_six_four() //录入班级选课.
{
struct school *p,*head;
struct classes *p2;
struct ban *p3;
FILE *fp1;
FILE *fp2;
int flag_1=0,flag_2=0,flag_3=0;
int i=0,j=0,n1,n2,n3;
char ch[100];
printf("\n\t\t欢迎进入 班级选课 界面\n");
printf("========================================================\n");
printf("\t\t请按提示选择要录入课程的班级\n");
printf("--------------------------------------------------------\n\n");
printf("\t温馨提示:请依次选择学院,专业,以及班级!\n");
printf("========================================================\n");
while(1)
{
j=0;
flag_1=0;flag_2=0;
head=p=(struct school *)malloc(SCH);
fp1=fopen("D:\\file\\school.txt","r");
j=0;
while(fread(p,SCH,1,fp1)!=0)
{
printf("%2d:%-20s",p->one,p->two);
j++;
if(j%3==0) putchar('\n');
}
printf("\n--------------------------------------------------------\n");
printf("请选择学院的编号,如01,按回车确定:");
scanf("%d",&n1);
ch[0]=getchar();
printf("--------------------------------------------------------\n");
rewind(fp1);
while(fread(p,SCH,1,fp1)!=0)
{
if(p->one ==n1) break;
}
j=0;
while(p->three[j]!=0)
{
printf("%d:%-20s",p->three[j] ,p->four[j] );j++;
if(j%2==0) putchar('\n');
}
fclose(fp1);
printf("\n--------------------------------------------------------\n");
printf("请选择专业的编码,按回车确定:");
scanf("%d",&n2 );
printf("请选择班级:");
scanf("%d",&n3);
printf("请选择该班级课程的编号,输入0表示结束:\n");
printf("--------------------------------------------------------\n");
fp2=fopen("D:\\file\\classes.txt","r");
p2=(struct classes*)malloc(CLA);
j=0;
while(fread(p2,CLA,1,fp2)!=0)
{
printf("%2d:%-10s",p2->one,p2->ch);j++;
if(j%4==0) putchar('\n');
}
fclose(fp2);
printf("\n--------------------------------------------------------\n");
p3=(struct ban*)malloc(sizeof(struct ban));
i=0;
do
{printf("请输入该班第%d门课程的编号:",i+1);
scanf("%d",&p3->four[i]);
i++;
}while(p3->four[i-1]!=0);
ch[0]=getchar();
printf("========================================================\n");
printf("1.确认\t2.返回\n");
while(1)
{
i=0;flag_3=0;
while((ch[i]=getchar())!='\n') i++;
if(i>1) ch[0]='9';
switch(ch[0])
{
case '1':flag_1=1;break;
case '2':flag_2=1;break;
default:{printf("输入有误 ,请重新输入:\n");flag_3=1;}
}
if(flag_3==0) break;
}
if(fla