C语言学生管理系统.docx
《C语言学生管理系统.docx》由会员分享,可在线阅读,更多相关《C语言学生管理系统.docx(58页珍藏版)》请在冰豆网上搜索。
![C语言学生管理系统.docx](https://file1.bdocx.com/fileroot1/2022-11/16/ca4d887c-2aa8-452e-a857-e18ca0652748/ca4d887c-2aa8-452e-a857-e18ca06527481.gif)
C语言学生管理系统
#include
#include
#include
#include
#defineM50
constcharstrStudentFilePath[]="studentInfo.txt";
constcharstrCourseFilePath[]="courseInfo.txt";
typedefstructMyInt
{
intnum;
structMyInt*next;
}CourseNumList,ScoreList;
structstudent
{
intnum;
charname[20];
charsex;
CourseNumList*courseNumList;//存放的是课程的序号
ScoreList*courseScore;//与上一个列表相对应的课程的成绩
intcourseSize;
intave;
}stu[M];
typedefstructstudentStudent;
intstuNum;//系统中存在的学生的记录数
typedefstructCourse
{
intnumCourse;
charname[20];
charteacherName[20];
structCourse*next;
}CourseList;
CourseList*pCourse=NULL;//头指针
CourseList*currentPoint=NULL;//工作指针
/*********************************************************************************************************
@函数名:
Initialize
@作用:
初始化系统的显示标头
@参数:
@返回值:
*********************************************************************************************************/
voidInitialize()
{
printf("\t\t********************************\n\n");
printf("\t\t学生成绩管理系统--C语言版\n");
printf("\n");
printf("\t\tCopyRightMaode,YAN\n");
printf("\n");
printf("\t\t********************************\n\n");
}
/*********************************************************************************************************
@函数名:
Exit
@作用:
当系统需要退出时,调用此函数停屏,与使用者交互
@参数:
@返回值:
*********************************************************************************************************/
voidExit()
{
printf("inputanykeytoquit!
");
getch();
exit(0);
}
voidSave();
/*********************************************************************************************************
@函数名:
InputStudentInfo
@作用:
输入学生信息,并保存在内存中
@参数:
@返回值:
@创建日期:
2012-05-13ByMaode,Yan
*********************************************************************************************************/
voidInputStudentInfo()
{
inti;
charisSave;
printf("\n开始输入学生信息,建立学生信息表:
\n");
printf("请输入学生人数:
");
scanf("%d",&stuNum);
if(stuNum>M)
{
printf("输入的学生数超过人数上线!
系统退出!
");
Exit();
}
for(i=0;i{
printf("请输入第%d个学生的学号:
\n",i);
scanf("%d",&stu[i].num);
printf("请输入第%d个学生的姓名:
\n",i);
scanf("%s",stu[i].name);
fflush(stdin);
printf("请输入第%d个学生的性别(Y代表男,N代表女):
\n",i);
scanf("%c",&stu[i].sex);
stu[i].courseNumList=NULL;
stu[i].courseScore=NULL;
stu[i].courseSize=0;
stu[i].ave=0;
}
fflush(stdin);
printf("是否保存学生信息到文件?
Y:
保存,N:
不保存:
");
scanf("%c",&isSave);
if(isSave=='Y'||isSave=='y')
{
Save(0);//0代表保存的是学生信息
printf("保存学生信息到文件操作已经完成!
");
}
else
{
fflush(stdin);
printf("选择不保存!
学生信息是系统运行基础,您确认不保存直接退出?
Y:
保存,N:
不保存:
");
scanf("%c",&isSave);
if(isSave!
='Y'&&isSave!
='y')
{
exit(0);
}
else
{
Save(0);
printf("保存课程信息到文件操作已经完成!
");
}
}
}
/*********************************************************************************************************
@函数名:
ShowOneStudentInfoWithoutScores
@作用:
输出学生信息,不包括成绩,仅仅有学号,名字和性别三个信息
@参数:
带输出学生的学号
@返回值:
*********************************************************************************************************/
voidShowOneStudentInfoWithoutScores(intStudentNum)
{
intk;
inti=StudentNum;
intleaveRoom;
chartemp[8];
memset(temp,'\0',8);
{
ltoa(stu[i].num,temp,10);
leaveRoom=6-strlen(temp);
printf("%d",stu[i].num);
for(k=0;k{
printf("");
}
memset(temp,'\0',8);
leaveRoom=0;
leaveRoom=8-strlen(stu[i].name);
printf("%s",stu[i].name);
for(k=0;k{
printf("");
}
leaveRoom=0;
if('Y'==stu[i].sex||'y'==stu[i].sex)
{
printf("男");
}
else
{
printf("女");
}
for(k=0;k<4;k++)
{
printf("");
}
}
}
/*********************************************************************************************************
@函数名:
InputCourseInfo
@作用:
输入课程信息
@参数:
@返回值:
*********************************************************************************************************/
voidInputCourseInfo()
{
intcourseSize;
charisSave;
charisContinue;
courseSize=0;
printf("\n开始输入课程,建立课程信息表:
\n");
while
(1)
{
fflush(stdin);
printf("如果输入完毕,请输入字符q结束输入,继续输入请输入字符n:
");
scanf("%c",&isContinue);
if('n'!
=isContinue&&'N'!
=isContinue)//如果输入不是继续,则退出
{
break;
}
else
{
CourseList*newPoint=(CourseList*)malloc(sizeof(structCourse));
if(newPoint==NULL)
{
printf("添加信息内存分配失败,按任意键退出系统");
getch();
exit(0);
}
else
{
fflush(stdin);
printf("请输入课程号:
\n");
scanf("%d",&(newPoint->numCourse));
fflush(stdin);
printf("请输入课程名称:
\n");
scanf("%s",newPoint->name);
fflush(stdin);
printf("请输入任课教师名称:
\n");
scanf("%s",newPoint->teacherName);
if(NULL==pCourse)
{
currentPoint=newPoint;