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.
xsxkxt/课程设计源代码_学生选课系统_1807_1840800...

228 lines
4.5 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct subject_info
{
int number;
char name[20];
int score;
int time;
int classtime;
int exprimenttime;
char term[10];
} subject;
typedef struct student_info
{
char xh[4];
char name[10];
int subject_num1;
int subject_num2;
} student;
subject sub;
student stu;
void infoinput() //<2F>γ<EFBFBD><CEB3><EFBFBD>Ϣ¼<CFA2><EFBFBD><EBBAAF>
{
FILE *fp;
fp=fopen("si.txt","a+");
if(fp==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!\n");
exit(0);
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ̱<EFBFBD><EFBFBD>ţ<EFBFBD>\n");
scanf("%d",&sub.number);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>\n");
scanf("%s",sub.name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD>ѧ<EFBFBD>֣<EFBFBD>\n");
scanf("%d",&sub.score);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD>ѧʱ<EFBFBD><EFBFBD>\n");
scanf("%d",&sub.time);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD>ѧʱ<EFBFBD><EFBFBD>\n");
scanf("%d",&sub.classtime);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>ѧʱ<EFBFBD><EFBFBD>\n");
scanf("%d",&sub.exprimenttime);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ڣ<EFBFBD>\n");
scanf("%s",sub.term);
fprintf(fp,"\n%d\t%s\t%d\t%d\t%d\t%d\t%s\t\n",sub.number,sub.name,sub.score,sub.time,sub.classtime,sub.exprimenttime,sub.term);
if(fclose(fp))
{
printf("<EFBFBD>޷<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
exit(0);
}
}
void studentinfo() //ѧ<><D1A7>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϣ¼<CFA2><C2BC>
{
FILE *fp;
fp=fopen("student.txt","a+");
if(fp==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!");
exit(0);
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%s",stu.xh);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",stu.name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>ĵ<EFBFBD>һ<EFBFBD>ſγ̵ı<EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&stu.subject_num1);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>ĵڶ<EFBFBD><EFBFBD>ſγ̵ı<EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&stu.subject_num2);
fprintf(fp,"\n%s\t%s\t%d\t%d\t\n",stu.xh,stu.name,stu.subject_num1,stu.subject_num2);
if(fclose(fp))
{
printf("<EFBFBD>޷<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");
exit(0);
}
}
void lookthrough() //<2F>γ<EFBFBD><CEB3><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
{
FILE *fp;
fp=fopen("si.txt","r");
if(fp==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!");
exit(0);
}
rewind(fp);
printf("ѡ<EFBFBD>޿γ<EFBFBD><EFBFBD><EFBFBD>Ϣһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tѧ<EFBFBD><EFBFBD>\tѧʱ\t<EFBFBD>ڿ<EFBFBD>ѧʱ\tʵ<EFBFBD><EFBFBD>ѧʱ\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>\n");
while(!feof(fp))
{
fscanf(fp,"%d\t%s\t%d\t%d\t%d\t%d\t%s\t",&sub.number,sub.name,&sub.score,&sub.time,&sub.classtime,&sub.exprimenttime,sub.term);
printf("\n%d\t%s\t%d\t%d\t%d\t %d\t %s\t\n",sub.number,sub.name,sub.score,sub.time,sub.classtime,sub.exprimenttime,sub.term);
}
if(fclose(fp))
{
printf("<EFBFBD>޷<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
exit(0);
}
}
void xh_cx() //<2F><>ѧ<EFBFBD>Ų<EFBFBD>ѯ
{char s[4];
char a[4]="";
FILE *fp;
int flag=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
scanf("%s",s);
fp=fopen("student.txt","r");
if(fp==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!");
exit(1);
}
rewind(fp);
while(!feof(fp))
{
fscanf(fp,"%s%s%d%d",stu.xh,stu.name,&stu.subject_num1,&stu.subject_num2);
strncpy(a,stu.xh,4);
if(strcmp(a,s)==0)
{
printf("%s\t%s\t%d\t%d\n",stu.xh,stu.name,stu.subject_num1,stu.subject_num2);
flag=1;
}
}
if(flag==0)
printf("Not Found!\n");
if(fclose(fp))
{
printf("<EFBFBD>޷<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");
exit(0);
}
}
void score_cx() //<2F><>ѧ<EFBFBD>ֲ<EFBFBD>ѯ
{
FILE *fp;
int xf,a;int flag=0;
fp=fopen("si.txt","r");
if(fp==NULL)
{
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!");
exit(1);
}
rewind(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>֣<EFBFBD>");
scanf("%d",&xf);
while(!feof(fp))
{
fscanf(fp,"%d\t%s\t%d\t%d\t%d\t%d\t%s\t",&sub.number,sub.name,&sub.score,&sub.time,&sub.classtime,&sub.exprimenttime,sub.term);
a=sub.score;
if(xf==a)
{
printf("%d\t%s\t%d\t%d\t%d\t%d\t%s\t\n",sub.number,sub.name,sub.score,sub.time,sub.classtime,sub.exprimenttime,sub.term);
flag=1;
}
}
if(flag==0)
printf("Not Found!\n");
if(fclose(fp))
{
printf("<EFBFBD>޷<EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");
exit(0);
}
}
int main()
{
int n;
do
{
printf("\nѧ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ϵͳ\n\n");
printf("------------------\n");
printf("| 1.<2E>γ<EFBFBD><CEB3><EFBFBD>Ϣ¼<CFA2><C2BC> |\n");
printf("| 2.ѡ<><D1A1><EFBFBD><EFBFBD>Ϣ¼<CFA2><C2BC> |\n");
printf("| 3.<2E>γ<EFBFBD><CEB3><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> |\n");
printf("| 4.<2E><>ѧ<EFBFBD>Ų<EFBFBD>ѯ |\n");
printf("| 5.<2E><>ѧ<EFBFBD>ֲ<EFBFBD>ѯ |\n");
printf("| 6.<2E>˳<EFBFBD> |\n");
printf("------------------\n\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>");
scanf("%d",&n);
switch(n)
{
case 1:
{
system("cls");
infoinput();
break;
}
case 2:
{
system("cls");
studentinfo();
break;
}
case 3:
{
system("cls");
lookthrough();
break;
}
case 4:
{
system("cls");
xh_cx();
break;
}
case 5:
{
system("cls");
score_cx();
break;
}
case 6:
{
system("cls");
printf("<EFBFBD><EFBFBD>ӭʹ<EFBFBD>ñ<EFBFBD>ϵͳ<EFBFBD><EFBFBD>лл<EFBFBD><EFBFBD>");
}
default:break;
}
} while(n!=6);
}