学生选课管理系统源代码Word文档下载推荐.docx
《学生选课管理系统源代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《学生选课管理系统源代码Word文档下载推荐.docx(9页珍藏版)》请在冰豆网上搜索。
intmenu();
intf1();
intluru();
intliulan();
intchaxun();
intxuanke();
inttongji();
printf("
\n*********************************************"
);
\n\n**********欢迎进入学生选课系统!
**********"
menu();
\n"
*******************theend*********************\n"
\n\n请先选择1进行课程信息录入:
"
scanf("
%d"
&
n);
//防止错误,请重新输入
for(;
n>
5||n<
0;
)
{
printf("
\n输入错误!
请重新输入!
\n"
scanf("
}
while(n>
0&
&
n<
6)
switch(n)
{
case1:
luru();
break;
//录入课程信息
case2:
liulan();
//浏览课程信息
case3:
chaxun();
//查询课程信息
case4:
xuanke();
//进入选课操作
case5:
tongji();
//统计选课情况
}
scanf("
//选择所需操作
for(;
printf("
\n\n"
请重新输入!
//防止错误,提示重新输入
system("
cls"
//清屏
}
if(n==0)
\n\n\n\n\n\n\n"
**********谢谢使用!
**********\n"
\n\n\n\n\n"
exit(0);
//退出选课系统
return0;
}
intmenu()//菜单函数
\n\n\n\n"
1.录入课程信息\n\n"
2.浏览课程信息\n\n"
3.查询课程信息\n\n"
4.进入选课操作\n\n"
5.统计选课情况\n\n"
0.退出选课系统\n\n"
intf1()
\n课程编号课程名称课程性质总学时学分开课学期:
intluru()//录入函数
FILE*fp;
//定义指向文件的指针
structcoursec;
inti;
if((fp=fopen("
D:
//course.txt"
"
w"
))==NULL)//建立文件"
course.txt"
cannotopenfile\n"
exit(0);
\n请输入选择的课程门数:
count);
f1();
for(i=0;
i<
count;
i++)
%d%s%s%d%d%d"
c.num,c.name,c.kind,&
c.ttime,&
c.mark,&
c.term);
fprintf(fp,"
%d\t%s\t%s\t%d\t%d\t%d\t"
c.num,c.name,c.kind,c.ttime,c.mark,c.term);
fclose(fp);
//关闭文件
\n*********录入成功!
*********\n"
intliulan()//浏览函数
inti=0;
//定义课程结构体变量
r"
))==NULL)//打开文件"
\ncannotopencourse!
while(!
feof(fp)&
count)
{fscanf(fp,"
%7d%11s%10s%9d%9d%8d\n"
i++;
intchaxun()//查询函数
intscore;
intb,i=0;
\n1.按学分查询\n"
\n2.按课程性质查询"
请选择查询方式\n\n输入选项数字:
b);
b<
1||b>
2;
}//按学分查询
if(b==1)
\n输入你要查询的学分:
"
score);
if((fp=fopen("
))==NULL)
exit(0);
f1();
while(!
count)//当没有指向文件尾部,读取文件“course.txt”中的数据
fscanf(fp,"
if(c.mark==score)//比较输入的分数和结构体中的分数,如果相同,输出那组数据
printf("
i++;
elseif(b==2)//按课程性质查询
\n\n输入你要查询的课程性质:
%s"
kind);
count)//当没有到达文件尾部,读取“course.txt”中的数据
if(strcmp(c.kind,kind)==0)//比较输入的字符串与原文件中的课程性质,如果相同,输出那组数据
else
输入错误!
//选择错误,就退出
exit
(1);
intxuanke()//选课函数
intt=0,flag;
/*structcoursec;
//定义课程结构体变量*/
do
\n请输入学号姓名课程编号及课程名称:
%d%s%d%s"
s[t].snum,s[t].snam,&
s[t].cnum,s[t].cnam);
feof(fp))//如果课程编号和课程名称与学生所选一致,就跳出,执行下一步
fscanf(fp,"
if((s[t].cnum==c.num)&
(s[t].cnam==c.name))
t++;
break;
}fclose(fp);
\n是否继续,是1,否0\n"
flag);
//student.txt"
a+"
))==NULL)//建立文件“student.txt”
\ncannotopenstudent!
}//建立,并将学生选课信息输入"
student.txt"
for(i=0;
t;
i++);
%d\t%s\t%d\t%s\t\n"
s[t].snum,s[t].snam,s[t].cnum,s[t].cnam);
//关闭选课文件"
}while(flag);
\n*********恭喜选课成功!
inttongji()//统计函数
inttotal=0;
intt,i=0;
))==NULL)//打开文件“student.txt”
\n学号姓名课程编号及课程名称\n"
feof(fp))//计数
%d%s%d%s\n"
s[i].snum,s[i].snam,&
s[i].cnum,s[i].cnam);
//读取文件“student.txt”
total++;
t=i;
%5d%6s%7d%10s\n"
s[i].snum,s[i].snam,s[i].cnum,s[i].cnam);
\n选课学生总人数为:
%d人"
total);
}