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.

46 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

void xuan_ke()//学生选修课程
{
int mai_n();
struct student s;
struct course c;
int a;
FILE *fp;
if((fp=fopen("course.txt","r"))==NULL)//文件没有内容报错
{
printf("\nCannot open course!\n");
}
printf("课程编号 课程名称 课程性质 总学时 授课学时 实验或上机学时 学分开课学期:\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);
printf("%5d%12s%9s%9d%9d%11d%11d%11d\n",c.num,c.name,c.kind,c.time,c.ttime,c.etime,c.mark,c.term);
}
fclose(fp);
printf("*@********#*******************************&****^**^*****&********************************#*****@**\n");
printf("\n 请输入您的学号 及 您要选择的课程编号:\n");
scanf("%d%d",&s.snum,&s.cnum);
if((fp=fopen("course.txt","r"))==NULL)
{
printf("\nCannot 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(s.cnum==c.num)
break;
}
fclose(fp);
if((fp=fopen("student.txt","a+"))==NULL)
{
printf("\nCannot open student!\n");
}
fprintf(fp,"%d %d %s\n",s.snum,s.cnum,c.name);
fclose(fp);
printf("\n1-返回菜单2-退出系统\n");
scanf("%d",&a);system("cls");//清屏
if(a==1)
mai_n();
else
exit(0);
}