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.
holrk/学生选修课程系统.cpp

193 lines
5.0 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct course
{
char name[100];
char kind[30];
int num;
int time;
int ttime;
int etime;
int mark;
int term;
};
struct student
{
char snum[11];
int cnum;
char cname[100];
};
void insert() /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ*/
{ int main();
FILE *fp;
struct course c;
int secret=112112;
int secret1;
int n;
system("cls");
if((fp=fopen("course.txt","a+"))==NULL)
{printf("cannot open course\n");}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&secret1);
if(secret1==secret)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
printf("<EFBFBD>γ̱<EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20><>ѧʱ <20>ڿ<EFBFBD>ѧʱ ʵ<><CAB5>ѧʱ ѧ<><D1A7> <20><><EFBFBD><EFBFBD>ѧ<EFBFBD>ڣ<EFBFBD>\n");
for(int i=1;i<=n;i++)
{
scanf("%d %s %s %d %d %d %d %d",&c.num,&c.name,&c.kind,&c.time,&c.ttime,&c.etime,&c.mark,&c.term);
fprintf(fp,"%d %s %s %d %d %d %d %d\n",c.num,c.name,c.kind,c.time,c.ttime,c.etime,c.mark,c.term);
}
}
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
fclose(fp);
main();
}
void browser() /*<2A><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>*/
{ int main();
FILE *fp;
struct course c;
system("cls");
if((fp=fopen("course.txt","r"))==NULL)
{printf("cannot open course\n");}
printf("<EFBFBD>γ̱<EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20><>ѧʱ <20>ڿ<EFBFBD>ѧʱ ʵ<><CAB5>ѧʱ ѧ<><D1A7> <20><><EFBFBD><EFBFBD>ѧ<EFBFBD>ڣ<EFBFBD>\n");
for(;!feof(fp);)
{
fscanf(fp,"%d%s%s%d%d%d%d%d",&c.num,&c.name,&c.kind,&c.time,&c.ttime,&c.etime,&c.mark,&c.term);
printf("%5d%12s%9s%9d%9d%11d%7d%7d\n",c.num,c.name,c.kind,c.time,c.ttime,c.etime,c.mark,c.term);
}
fclose(fp);
main();
}
void search() /*<2A><>Ϣ<EFBFBD><CFA2>ѯ*/
{ int main();
FILE *fp;
struct course c;
int score,b;
system("cls");
loop:
printf("1.<2E><>ѧ<EFBFBD>ֲ<EFBFBD>ѯ 2.<2E><><EFBFBD>γ<EFBFBD><CEB3><EFBFBD><EFBFBD>ʲ<EFBFBD>ѯ\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>");
scanf("%d",&b);
if(b==1)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%d",&score);
if((fp=fopen("course.txt","r"))==NULL)
{
printf("cannot open course!\n");
}
else
printf("<EFBFBD>γ̱<EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20><>ѧʱ <20>ڿ<EFBFBD>ѧʱ ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ѧʱ ѧ<><D1A7> <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>:\n");
for(;!feof(fp);)
{
fscanf(fp,"%d%s%s%d%d%d%d%d",&c.num,&c.name,&c.kind,&c.time,&c.ttime,&c.etime,&c.mark,&c.term);
if(score==c.mark)
printf("%5d%12s%9s%9d%9d%11d%7d%7d\n",c.num,c.name,c.kind,c.time,c.ttime,c.etime,c.mark,c.term);
}
}
else if(b==2)
{
char kind1[10];
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD>Ŀγ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",&kind1);
if((fp=fopen("course.txt","r"))==NULL)
{
printf("cannot open course!\n");
}
else
printf("<EFBFBD>γ̱<EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> <20><>ѧʱ <20>ڿ<EFBFBD>ѧʱ ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ϻ<EFBFBD>ѧʱ ѧ<><D1A7> <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>:\n");
for(;!feof(fp);)
{
fscanf(fp,"%d%s%s%d%d%d%d%d\n",&c.num,&c.name,&c.kind,&c.time,&c.ttime,&c.etime,&c.mark,&c.term);
if(strcmp(c.kind,kind1)==0)
printf("%5d%12s%9s%9d%9d%11d%10d%10d\n",c.num,c.name,c.kind,c.time,c.ttime,c.etime,c.mark,c.term);
}
}
else
{ printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"); goto loop;}
fclose(fp);
main();
}
void xuankeinformation() /*ѧ<><D1A7>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{ int main();
FILE *fp;
struct student s;
system("cls");
if((fp=fopen("student.txt","r"))==NULL)
{
printf("cannot open course!\n");
}
printf(" ѧ<><D1A7> <20>γ̱<CEB3><CCB1><EFBFBD> <20>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD> \n");
for(;!feof(fp);)
{
fscanf(fp,"%s %d %s",&s.snum,&s.cnum,&s.cname);
printf("%7s %5d %17s\n",s.snum,s.cnum,s.cname);
}
fclose(fp);
main();
}
void xuanke() /*ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>*/
{
int main();
FILE *fp;
struct student s;
struct course c;
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>Ŀγ̵ı<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%s %d",&s.snum,&s.cnum);
if((fp=fopen("course.txt","r"))==NULL)
{
printf("cannot open course!\n");
}
for(;!feof(fp);)
{
fscanf(fp,"%d %s %s %d %d %d %d %d\n",&c.num,&c.name,&c.kind,&c.time,&c.ttime,&c.etime,&c.mark,&c.term);
if(c.num==s.cnum)
break;
}
fclose(fp);
if((fp=fopen("student.txt","a+"))==NULL)
{
printf("cannot open student!\n");
}
fprintf(fp,"%s %d %s\n",s.snum,s.cnum,c.name);
fclose(fp);
main();
}
int main()
{
loop:
printf("\n\n");
printf(" ѧ<><D1A7>ѡ<EFBFBD>޿γ<DEBF>ϵͳ \n\n\n");
printf(" ******** 1.<2E>γ<EFBFBD><CEB3><EFBFBD>Ϣ¼<CFA2><C2BC> ******** \n");
printf(" ******** 2.<2E>γ<EFBFBD><CEB3><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> ******** \n");
printf(" ******** 3.<2E>γ<EFBFBD><CEB3><EFBFBD>Ϣ<EFBFBD><CFA2>ѯ ******** \n");
printf(" ******** 4.ѧ<><D1A7>ѡ<EFBFBD>޿γ<DEBF>ͳ<EFBFBD><CDB3> ******** \n");
printf(" ******** 5.ѡ<><D1A1> ******** \n");
printf(" ******** 0.<2E>˳<EFBFBD> ******** \n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
int x;
scanf("%d",&x);
switch(x)
{
case 1:insert();break;
case 2:browser(); break;
case 3:search(); break;
case 4:xuankeinformation(); break;
case 5:xuanke(); break;
case 0:exit(0);break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); goto loop;
}
return 0;
}