C++程序实验报告Word文档下载推荐.docx

上传人:b****6 文档编号:19683493 上传时间:2023-01-08 格式:DOCX 页数:20 大小:188.83KB
下载 相关 举报
C++程序实验报告Word文档下载推荐.docx_第1页
第1页 / 共20页
C++程序实验报告Word文档下载推荐.docx_第2页
第2页 / 共20页
C++程序实验报告Word文档下载推荐.docx_第3页
第3页 / 共20页
C++程序实验报告Word文档下载推荐.docx_第4页
第4页 / 共20页
C++程序实验报告Word文档下载推荐.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

C++程序实验报告Word文档下载推荐.docx

《C++程序实验报告Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《C++程序实验报告Word文档下载推荐.docx(20页珍藏版)》请在冰豆网上搜索。

C++程序实验报告Word文档下载推荐.docx

不要局限于题目所规定的要求,可以灵活裁减,设计出功能更完善的程序。

工作量

完成所选题目的程序设计;

课程设计说明书

工作计划

第1次熟悉软件环境。

第2次绘制程序流程图。

第3次用编写程序。

第4次用调试运行程序。

第5次编写课程设计说明书

参考资料

《VisualC++面向对象程序设计教程与实验》,温秀梅、丁学钧主编,第二版,北京:

清华大学出版社,2009.4

1题目与要求

1.1问题提出

学生信息包括:

学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。

试设计一学生信息管理系统,使之能提供以下功能:

系统以菜单方式工作,学生信息录入功能(学生信息用文件保存)输入学生信息浏览功能,输出查询排序功能算法

按学号查询按姓名查询学生信息的删除与修改

1.2本系统涉及的知识点

结构、指针、循环、数组、函数、宏定义

1.3功能要求

1、录入学生信息,每个学生的信息包括:

学号、姓名、性别、班级、手机号、邮箱号;

2、查询学生信息;

3、排序:

分别按平均分排序、按学号排序;

4、根据学号查询成绩;

5、修改学生信息;

1.4问题分析

定义不同的函数,实现信息管理系统各项功能。

其中,学生信息包括:

实现功能包括:

学生信息录入功能,学生信息浏览功能,查询,排序功能,按学号查询,学生信息的删除与修改等。

2功能设计

2.1显示界面

2.2部分模块流程图

3程序代码设计

头文件:

#include"

stdafx.h"

#include<

stdio.h>

/*I/o函数*/

stdlib.h>

/*其他说明*/

string.h>

iostream>

usingnamespacestd;

conio.h>

iomanip>

#defineLEN30/*学号和姓名最大学生人数*/

#defineN100/*最大学生人数*/

structstudent/*声明函数体*/

{

charcode[20];

/*学号*/

charname[10];

/*姓名*/

intage;

/*年龄*/

charsex[5];

/*性别*/

chartime[20];

/*出生年月*/

charadd[20];

/*家庭地址*/

chartel[20];

/*电话*/

charmail[20];

/*邮箱地址*/

}stu[N];

intk=1,m,n;

student*shuru_information(student*);

student*chaxun_information(student*);

student*xiugai_information(student*);

student*zengjia_information(student*);

student*shanchu_information(student*);

student*xianshi_information(student*);

student*baocun_information(student*);

student*caidan_information(student*);

student*tuichuxitong_information(student*);

student*huanyingyemian_information(student*);

student*help_information(student*);

student*paixu_information(student*);

主函数:

intmain()

student*head;

while(k)

{

head=huanyingyemian_information(head);

system("

pause"

);

cls"

cout<

<

"

请按任意键进入主菜单!

endl;

head=caidan_information(head);

}

return0;

}

系统帮助说明函数:

student*help_information(student*head)

{

COLOR3f"

\n尊敬的用户您好!

//cout<

\n============================================================|"

|"

cout<

\n1.欢迎进入帮助系统!

"

★★★★★★★★"

2.请按照菜单提示进入数字代号!

3.增加学生信息后,请切记保存!

4.谢谢您的使用!

============================================================"

;

return(head);

学生信息输入函数:

student*shuru_information(student*head)/*实现录入学生基本信息功能*/

inti,flag=1;

while(flag)

flag=0;

请输入需要创建信息的学生人数(1-100):

scanf("

%d"

&

n);

if(n<

1||n>

100)

flag=1;

输入错误,检查后请重新输入!

endl;

for(i=0;

i<

n;

i++)

请输入第%d个学生的基本信息:

\n"

i+1;

请输入学号:

cin>

>

stu[i].code;

请输入姓名:

stu[i].name;

getchar();

请输入性别(男,女):

stu[i].sex;

请输入年龄:

stu[i].age;

请输入出生年月(输入格式:

年.月):

stu[i].time;

请输入家庭地址:

stu[i].add;

请输入电话号码:

stu[i].tel;

请输入E-mail地址:

stu[i].mail;

录入完毕!

head=baocun_information(head);

student*baocun_information(student*head)/*保存学生信息到文件的函数*/

inti;

FILE*fp;

if((fp=fopen("

student.txt"

"

wb"

))==NULL)/*创建文件并判断是否能够打开成功*/

文件不能打开!

exit(0);

/*如果不能打开文件,则关闭当前所有的文件*/

i++)/*将内存中的学生信息写入到磁盘文件中*/

if(fwrite(&

stu[i],sizeof(structstudent),1,fp)!

=1)

文件输入错误!

fclose(fp);

学生信息查询:

student*chaxun_information(student*head)

inti,t,flag;

chars1[30];

COLOR5f"

\n=================================\n"

|1.按学号查询|\n"

|2.按姓名查询|\n"

|3.退出本菜单|\n"

=================================\n"

while

(1)

请输入子菜单编号:

cin>

t;

switch(t)

case1:

请输入要查询的学生的学号:

\n"

s1;

if(strcmp(stu[i].code,s1)==0)

学生学号"

stu[i].code;

\n学生姓名"

\n年龄"

\n性别"

\n出生年月"

\n家庭地址"

\n电话"

\nE-mail"

}

if(flag==0)

该学号不存在!

break;

case2:

请输入要查询的学生的姓名:

if(strcmp(stu[i].name,s1)==0)

学生学号学生姓名年龄性别出生年月家庭地址电话E-mail\n"

================================================================================\n"

%6s%7s%6d%5s%9s%8s%10s%14s\n"

stu[i].code,stu[i].name,stu[i].age,stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail;

该姓名不存在!

case3:

return(head);

default:

请在1--3之间选择\n"

return(head);

修改学生信息:

student*xiugai_information(student*head)

inti,t,num;

charsex1[3],s1[30],s2[30];

num=i;

COLOR4f"

=============================================\n"

|1.修改姓名|\n"

|2.修改年龄|\n"

|3.修改性别|\n"

|4.修改出生年月|\n"

|5.修改地址|\n"

|6.修改电话号码|\n"

|7.修改E-mail|\n"

|8.修改退出本菜单|\n"

while

(1)

请输入子菜单的编号:

case1:

请输入新的姓名:

s2;

strcpy(stu[num].name,s2);

case2:

请输入新的年龄:

stu[num].age;

case3:

case4:

请输入新的出生年月:

strcpy(stu[num].time,s2);

break;

case5:

请输入新的地址:

strcpy(stu[num].add,s2);

case6:

请输入新的电话号码:

strcpy(stu[num].tel,s2);

case7:

请输入新的E-mail:

strcpy(stu[num].mail,s2);

case8:

请在1--8之间选择\n"

return(head);

对学生信息进行排序:

student*paixu_information(student*head)

inti,j,*p,*q,s;

chartemp[10];

n-1;

for(j=n-1;

j>

i;

j--)

if(strcmp(stu[j-1].code,stu[j].code)>

0)

{

strcpy(temp,stu[j-1].code);

strcpy(stu[j-1].code,stu[j].code);

strcpy(stu[j].code,temp);

strcpy(temp,stu[j-1].name);

strcpy(stu[j-1].name,stu[j].name);

strcpy(stu[j].name,temp);

strcpy(temp,stu[j-1].sex);

strcpy(stu[j-1].sex,stu[j].sex);

strcpy(stu[j].sex,temp);

strcpy(temp,stu[j-1].time);

strcpy(stu[j-1].time,stu[j].time);

strcpy(stu[j].time,temp);

strcpy(temp,stu[j-1].add);

strcpy(stu[j-1].add,stu[j].add);

strcpy(stu[j].add,temp);

strcpy(temp,stu[j-1].tel);

strcpy(stu[j-1].tel,stu[j].tel);

strcpy(stu[j].tel,temp);

strcpy(temp,stu[j-1].mail);

strcpy(stu[j-1].mail,stu[j].mail);

strcpy(stu[j].mail,temp);

p=&

stu[j-1].age;

q=&

stu[j].age;

s=*p;

*p=*q;

*q=s;

}return(head);

增加学生信息:

student*zengjia_information(student*head)

inti=n,j,flag;

请输入将要增加的学生数目:

m;

do

请输入第%d个学生的学号:

for(j=0;

j<

j++)

if(strcmp(stu[i].code,stu[j].code)==0)

该学号已经存在,请仔细核查后重新输入!

请输入第%d个学生的学生姓名:

请输入第%d个学生的学生年龄:

请输入第%d个学生的学生性别:

请输入第%d个学生的学生出生年月:

(格式:

年,月,日)\n"

请输入第%d个学生的学生家庭地址:

请输入第%d个学生的学生电话:

请输入第%d个学生的学生E-mail:

if(flag==0)

i++;

}while(i<

n+m);

n=n+m;

输入完毕!

\n\n"

head=paixu_information(head);

删除学生信息:

student*shanchu_information(student*head)

inti,j,flag=0;

chars1[15];

请输入将要删除的学生的学号:

for(i=1;

for(j=i;

stu[j]=stu[j+1];

if(flag==1)

删除成功!

显示结果请按6!

n--;

}return(head);

student*xianshi_information(student*head)

rb"

))==NULL)

打开文件时错误!

请按任意键退出!

所有学生的信息为:

\n\n"

学生学号学生姓名年龄性别出生年月家庭地址电话E-mail"

================================================================================"

i++)

{fread(&

stu[i],sizeof(structstudent),1,fp);

stu[i].code,stu[i].name,stu[i].age,stu[i].sex,stu[i].time,stu[i].add,stu[i].tel,stu[i].mail;

退出系统:

student*tuichuxitong_information(student*head)

system("

--------【学生信息管理系统】-------\n"

指导老师:

郝伟\n"

●☆☆Bye-Bye☆☆●\n"

★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n"

☆☆☆☆☆☆☆☆☆☆☆\n"

★★★★★★★★★★★\n"

安★物\n"

徽★联\n"

理★网\n"

工★工\n"

大★工\n"

学★程\n"

★一\n"

★班\n"

◆谢谢使用◆\n"

显示主界面:

student*huanyingyemian_information(student*head)

{system("

COLOR6f"

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1