C++课程设计 学生管理系统

使用下面的数据,用C/C++设计一个简单的学籍管理系统,实现出最基本的功能。
学生基本信息文件(A.TXT)及其内容:A.TXT文件不需要编程录入数据,可用文本编辑工具直接生成
学号 姓名 性别 宿舍号码 电话号码
01 张成成 男 501 87732111
02 李成华 女 101 87723112
03 王成凤 女 101 87723112
04 张明明 男 502 87734333
05 陈东 男 501 87732111
06 李果 男 502 87734333
07 张园园 女 102 87756122
… …. .. … ………..
学生成绩基本信息文件(B.TXT)及其内容:
学号 课程编号 课程名称 学分 平时成绩 实验成绩 卷面成绩 综合成绩 实得学分
01 A01 大学物理 3 66 78 82
02 B03 高等数学 4 78 -1 90
01 B03 高等数学 4 45 -1 88
02 C01 VF 3 65 76 66
… …. ………. .. .. …

(一) 功能要求及说明:
(1) 数据录入功能: 对B.TXT进行数据录入,只录入每个学生的学号、课程编号、课程名称、学分、平时
成绩、实验成绩、卷面成绩共7个数据. 综合成绩、学分由程序根据条件自动运算。
综合成绩的计算:如果本课程的实验成绩为-1,则表示无实验,综合成绩=平时成绩*30%+卷面成绩*70%;
如果实验成绩不为-1,表示本课程有实验,综合成绩=平时成绩*15%+实验成绩*.15%+卷面成绩*70% .
实得学分的计算: 采用等级学分制.
综合成绩在90-100之间 ,应得学分=学分*100% 综合成绩在80-90之间 ,应得学分=学分*80%
综合成绩在70-80之间 ,应得学分=学分*75% 综合成绩在60-70之间 ,应得学分=学分*60%
综合成绩在60以下 ,应得学分=学分*0%
(2)查询功能:分为学生基本情况查询和成绩查询两种
A:学生基本情况查询:
A1----输入一个学号或姓名(可实现选择),查出此生的基本信息并显示输出。
A2---输入一个宿舍号码,可查询出本室所有的学生的基本信息并显示输出。
B:成绩查询:
B1:输入一个学号时,查询出此生的所有课程情况,格式如下:
学 号:xx 姓 名:xxxxx
课程编号:xxx 课程名称:xxxxx 综合成绩:xxxx 实得学分: xx
课程编号:xxx 课程名称:xxxxx 综合成绩:xxxx 实得学分: xx
课程编号:xxx 课程名称:xxxxx 综合成绩:xxxx 实得学分: xx
… … … … ……… … …
共修:xx科,实得总学分为: xxx
(3)删除功能:当在A.TXT中删除一个学生时,自动地在B.TXT中删除此人所有信息。
(4 ) 排序功能:能实现选择按综合成绩或实得学分升序或降序排序并显示数据。
(二)其它要求:
(1) 只能使用C/C++语言,源程序要有适当的注释,使程序容易阅读
(2) 至少采用文本菜单界面(如果能采用图形菜单界面更好)
(3) 学生可自动增加新功能模块(视情况可另外加分)
(4)写出课程设计报告,具体要求见相关说明文档
十万火急,哪位好心人帮帮忙.谢了啊!!!

#include<stdio.h>
基本上和你的一模一样,运行完全正确

#include<stdlib.h>
#include<conio.h>
#include<string.h>

struct student_info
{ char number[15]; /*学号*/
char name[20]; /*姓名*/
char gender[8]; /*性别*/
char sushe_no[10]; /*宿舍号*/
char tel[20];
};

struct student_grade
{
char number[15];
char courseno[10]; /*课程号*/
char coursename[20]; /*课程名称*/
int xuefen;
int pingshicj;
int shiyancj;
int juanmiancj;
float zonghecj;
float shidecj;
};

typedef struct student_info stu_info;
typedef struct student_grade stu_grade;

int CourseInfoIndex=0;
int StudentInfoIndex=0;

stu_info *StuInfo=NULL;
stu_grade *StuCour=NULL;

int ReadStuInfo(void) //从原有的学生信息文件中读取信息
{
FILE *fp;

StudentInfoIndex=0;

if((fp=fopen("a.txt","rb"))==NULL)
{
return -1;
}
else
{
while(!feof(fp))
{
if(fread(&StuInfo[StudentInfoIndex],sizeof(stu_info),1,fp)==1)
{
StudentInfoIndex++;
}
}
fclose(fp);

return 0;
}
}

int WriteStuInfo(void) //将学生信息写入到文件中
{
FILE *fp;

if(StudentInfoIndex>=0)
{
if((fp=fopen("a.txt","wb"))==NULL)
{
return -1;
}
else
{
fwrite(StuInfo,sizeof(stu_info)*StudentInfoIndex,1,fp);
fclose(fp);
return 0;
}
}

return 0;
}

void PrintStuInfo(int index)
{
int i=0;

ReadStuInfo();

printf("\nNow print the data of student infomation:\n");
printf("StuNO StuName Gender SuSheHao Telphone\n");
if (index==-1)
{
for(i=0;i<=StudentInfoIndex-1;i++)
{
printf("%s ",StuInfo[i].number);
printf("%s ",StuInfo[i].name);
printf("%s ",StuInfo[i].gender);
printf("%s ",StuInfo[i].sushe_no);
printf("%s\n",StuInfo[i].tel);
}
}
else
{
printf("%s ",StuInfo[index].number);
printf("%s ",StuInfo[index].name);
printf("%s ",StuInfo[index].gender);
printf("%s ",StuInfo[index].sushe_no);
printf("%s\n",StuInfo[index].tel);
}
}

void InStuInfo(void) //添加学生信息
{
int t=0;
char str[20];

ReadStuInfo();

//PrintStuInfo(-1); //测试代码,打印学生信息

printf("Now you will input some new student infomation records,\n end with a * for begin of a record.\n");

while(str[0]!='*')
{
t++;

printf("-------------------------------------\n");
printf("Now Please input the %dth record:\n",t);

printf(" Student no:");
gets(str);
if(str[0]=='*')
{
continue;
} //如果碰到结束标志

strcpy(StuInfo[StudentInfoIndex].number,str);

printf("\n Student name:");
gets(StuInfo[StudentInfoIndex].name);

printf("\n Student gender:");
gets(StuInfo[StudentInfoIndex].gender);

printf("\n sushe_no:");
gets(StuInfo[StudentInfoIndex].sushe_no);

printf("\n tel:");
gets(StuInfo[StudentInfoIndex].tel);

StudentInfoIndex++;

}

WriteStuInfo();

}

int ReadCourseInfo(void) //从原有的学生成绩信息文件中读取信息
{
FILE *fp;

CourseInfoIndex=0;

if((fp=fopen("b.txt","rb"))==NULL)
{
return -1;
}
else
{
while(!feof(fp))
{
if(fread(&StuCour[CourseInfoIndex],sizeof(stu_grade),1,fp)==1)
{
CourseInfoIndex++;
}
}
fclose(fp);

return 0;
}
}

int WriteCourseInfo(void) //将成绩信息写入到文件中
{
FILE *fp;

if(CourseInfoIndex>=0)
{
if((fp=fopen("b.txt","wb"))==NULL)
{
return -1;
}
else
{
fwrite(StuCour,sizeof(stu_grade)*CourseInfoIndex,1,fp);
fclose(fp);
return 0;
}
}

return 0;
}

void PrintCourseInfo(int index)
{
int i=0;

ReadCourseInfo();

printf("\nNow print the data of course infomation:\n");
printf("StuNO CourseNo CourseName XueFen PingShiCJ ShiYanCJ JuanMianCJ ZongHeCJ ShiDeCJ\n");
if (index==-1)
{
for(i=0;i<=CourseInfoIndex-1;i++)
{
printf("%s ",StuCour[i].number);
printf("%s ",StuCour[i].courseno);
printf("%s ",StuCour[i].coursename);
printf("%d ",StuCour[i].xuefen);
printf("%d ",StuCour[i].pingshicj);
printf("%d ",StuCour[i].shiyancj);
printf("%d ",StuCour[i].juanmiancj);
printf("%f ",StuCour[i].zonghecj);
printf("%f\n",StuCour[i].shidecj);
}
}
else
{
printf("%s ",StuCour[index].number);
printf("%s ",StuCour[index].courseno);
printf("%s ",StuCour[index].coursename);
printf("%d ",StuCour[index].xuefen);
printf("%d ",StuCour[index].pingshicj);
printf("%d ",StuCour[index].shiyancj);
printf("%d ",StuCour[index].juanmiancj);
printf("%f ",StuCour[index].zonghecj);
printf("%f\n",StuCour[index].shidecj);
}
}

void InStuCourseInfo(void) //输入新的学生成绩信息
{
int t=0;
char str[20];

ReadCourseInfo(); //先把原先文件中存在的记录读到内存中

// PrintCourseInfo(-1); //测试代码过程

printf("Now you will input some new student course records,\n end with a * for begin of a record.\n");

while(str[0]!='*')
{
t++;
printf("-------------------------------------\n");
printf("Now Please input the %dth record:\n",t);

printf(" Student no:");
gets(str);
if(str[0]=='*')
{
//if(CourseInfoIndex!=0) CourseInfoIndex--;
continue;
} //如果碰到结束标志

strcpy(StuCour[CourseInfoIndex].number,str);

printf("\n Course no:");
gets(StuCour[CourseInfoIndex].courseno);

printf("\n Course name:");
gets(StuCour[CourseInfoIndex].coursename);

printf("\n XueFen:");
gets(str);
StuCour[CourseInfoIndex].xuefen=(int)atof(str);

printf("\n PingShiChengJi:");
gets(str);
StuCour[CourseInfoIndex].pingshicj=(int)atof(str);

printf("\n ShiYanChengJi:");
gets(str);
StuCour[CourseInfoIndex].shiyancj=(int)atof(str);

printf("\n JuanMianChengJi:");
gets(str);
StuCour[CourseInfoIndex].juanmiancj=(int)atof(str);

//下面计算综合成绩和实得成绩

if(StuCour[CourseInfoIndex].shiyancj==-1)
{
StuCour[CourseInfoIndex].zonghecj=StuCour[CourseInfoIndex].pingshicj*0.3+StuCour[CourseInfoIndex].juanmiancj*0.7;
}
else
{
StuCour[CourseInfoIndex].zonghecj=StuCour[CourseInfoIndex].shiyancj*0.15+StuCour[CourseInfoIndex].pingshicj*0.15+StuCour[CourseInfoIndex].juanmiancj*0.7;
}

if(StuCour[CourseInfoIndex].zonghecj>=90)
{
StuCour[CourseInfoIndex].shidecj=StuCour[CourseInfoIndex].xuefen*1.0;
}
else
{
if(StuCour[CourseInfoIndex].zonghecj>=70)
{
StuCour[CourseInfoIndex].shidecj=StuCour[CourseInfoIndex].xuefen*0.8;
}
else
{
if(StuCour[CourseInfoIndex].zonghecj>=60)
{
StuCour[CourseInfoIndex].shidecj=StuCour[CourseInfoIndex].xuefen*0.6;
}
else
{
StuCour[CourseInfoIndex].shidecj=0.0;
}
}
}

CourseInfoIndex++;
}

WriteCourseInfo();// 保存到文件中
}

/* 将src指向的一条记录复制给dest指向的记录 */
void CopyStuInfo(stu_info *src,stu_info *dest)
{
int j;
strcpy(dest->number,src->number);
strcpy(dest->name,src->name);
strcpy(dest->gender,src->gender);
strcpy(dest->sushe_no,src->sushe_no);
strcpy(dest->tel,src->tel);
}

void Del(void)
{
char strdel[15];
int p=0;
int flag=0;
int t=StudentInfoIndex;

printf("Delete a student infomation record:\n");

ReadCourseInfo();
ReadStuInfo();
PrintStuInfo(-1); //打印学生信息

printf("Please input the student number which you will delete:");
gets(strdel);

while(p<=t && flag==0)
{
if(strcmp(strdel,StuInfo[p].number)==0)
{
flag=1; //找到该学号的记录
CopyStuInfo(&StuInfo[t-1],&StuInfo[p]); //将最后一个记录覆盖当前记录,如果找到的是最后一个记录,则直接丢失
t--;
StudentInfoIndex--;
}
else
{
p++;
}
}

if(flag==1) //如果删除了a文件的记录,则应相应的删除b文件的记录
{
p=0;
t=CourseInfoIndex;
while(p<=t && CourseInfoIndex>=0 )
{
if(strcmp(strdel,StuCour[p].number)==0)
{
CopyStuInfo(&StuCour[CourseInfoIndex-1],&StuCour[p]);
CourseInfoIndex--;
t--;
}
else
{
p++;
}
}
}

WriteStuInfo();
WriteCourseInfo();

PrintStuInfo(-1);
PrintCourseInfo(-1);

}

/* 将src指向的一条记录复制给dest指向的记录 */
void CopyCourseInfo(stu_grade *src,stu_grade *dest)
{
int j;
strcpy(dest->number,src->number);
strcpy(dest->courseno,src->courseno);
strcpy(dest->coursename,src->coursename);
dest->xuefen=src->xuefen;
dest->pingshicj=src->pingshicj;
dest->juanmiancj=src->juanmiancj;
dest->zonghecj=src->zonghecj;
dest->shidecj=src->shidecj;
}

void SortInfo(void)
{
char str[5];
int i,j;
stu_grade tmps;

printf("Pease select a sorting way:\n");
printf("1.with zonghecj in inc order\n");

此部分被隐藏。。。给分数后再发给你
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-07-03
我们也是这个啊,命苦哦~~~
如果可以也发给我一份吧!!
就当是江湖救急啊~~
谢谢了!!!
[email protected]
第2个回答  2008-06-26
同是天涯沦落人
第3个回答  2008-07-02
有缘啊,我也要做这个,做好了发给我好么?我的邮箱是[email protected]
第4个回答  2008-07-11
我会帮你看看的
相似回答