ImageVerifierCode 换一换
格式:DOCX , 页数:55 ,大小:272.99KB ,
资源ID:5095258      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5095258.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c加加动态数组加无限内存人员管理系统.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c加加动态数组加无限内存人员管理系统.docx

1、c加加动态数组加无限内存人员管理系统“信息与计算科学”专业C+语言程序设计课程设计 班级 计算科学 姓名 学号 指导教师 设计日期 2016春19周20周 (一)、设计菜单选择程序。菜单是应用程序的界面,通过控制语句改变程序执行的顺序,设计菜单是程序设计的基础。本设计分两步:第一步:设计一个菜单程序。1菜单内容:程序运行后,给出3个菜单项的内容和输入提示,如下:1)利用克莱姆法则求解线性方程组2)统计一篇英文文章的单词数3)退出程序第二步:为上述菜单项配上相应的功能。1.流程图:2.程序优缺点:优点: 采用了 动态开辟二维数组,传递不知道大小的二维数组,程序规范,可读性强。缺点:采用递归算法,

2、增加了程序的时间复杂度。3.代码段:#include#include#include #includeusing namespace std;double *open_up(int row,int line);double Price(int row,int line,double *a); void Head();void Cramer();void Statis_Words();int main() char ch; / 选择变量 while(1) Head(); couttt选择要进行的程序:endl; ch = cin.get(); coutendl; switch(ch) case

3、1:system(cls);Cramer();break; case 2:system(cls);Statis_Words();break; case 3:system(cls); cout 退出程序 endl; exit(0);break; default :system(cls);couttt 输入有误 endl; cin.get(); return 0;void Head() couttt 菜单选择程序 endl; couttt endl; couttt endl; couttt 1.克莱姆法则解线性方程组 endl; couttt 2.统计英语文章单词数 endl; couttt 3.

4、 结 束 endl; couttt endl; couttt endl; void Cramer() int m = 0,n = 0,i = 0,k = 0,j = 0,h = 0; double Quit = 0.0,l = 0.0; double *a = open_up(15,15); /动态开辟二维数组 double *e = open_up(15,15); /动态开辟二维数组 double *T = open_up(15,15); /动态开辟二维数组 double *W = open_up(15,15); /动态开辟二维数组 double P15 = 0.0,d15 = 0.0; c

5、out tt克莱姆法则计算矩阵的值 endl; cout 输入所求线性方程组的系数矩阵; cout 输入行数m和列数n m n; cout输入矩阵endl; for(i = 0;i m;i+) for(j = 0;j aij; coutendl; Quit = Price(n,n,(double *)a); cout 系数矩阵的值为:Quitendl; cout输入方程组的解矩阵endl; for(i = 0;i di; for(i = 0;i m;i+) for(j = 0;j n;j+) eij = aij; for(j = 0;j n;j+) for(i = 0;i m;i+) aij

6、= di; for(i = 0;i m;i+) Pj = Price(n,n,(double*)a)/Quit; /强制类型转换 cout x j = Pj endl; for(h = 0;h m;h+) /重置矩阵 ahj = ehj; void Statis_Words() char ch = 0; int count = 0,word = 0; cout输入一片英语文章 以零结尾n = 0 & ch = 91 & ch 122 & ch 127) /判断是否为 word = 0; else if(0 = word) word = 1; count+; cout文章一共有count个单词e

7、ndl;double Price(int row,int line,double *a)/求矩阵行列式的递归函数 int i = 0,j = 0,c = 0,p = 0,q = 0; double sum = 0; double *ele = open_up(row,line); /动态开辟二维数组 if(row = 1) return *a; for(i = 0;i row;i+) /递归法求解行列式的值 for(c = 0;c row;c+) if(c i) p=0; else p=1; for(j = 0;j row - 1;j+) elecj = *( a+row*(c+p) + (j

8、+1) ); if(i % 2 = 0) q = 1; else q = -1; sum += *(a+i*row+0) * q * Price(row-1,row-1,(double *)ele); return sum;double *open_up(int row,int line) / 动态开辟二维数组 double *ele = new double *row; for (int i = 0; i row; i+) elei = new doubleline; return ele; 4.程序运行截图:(二)、有理数的四则运算。 有理数就是两个整数的比率,通常表示为,分母不能为0。

9、本设计要求设计一个Rational(有理数)类,实现有理数的四则运算,该类型的对象使用起来要像使用基本类型的对象一样自然。具体要求如下:1抽象Ration类,包含两个数据成员(分子、分母),比如有理数可以用对象表示为。2如果分子分母有公约数,应该约分,例如应表示为。根据需要,有时要将表示为,或者将表示为重载相应的运算符(输入、输出、加、减、乘、除)。比如,要计算,希望像普通加法一样操作,和相加得,算数表达式为。又如,想使用如下形式直接输入分子分母 cin r; /输出则需要重载这两个流运算符。1.流程图: 2.程序优缺点:优点: 采用了友元函数实现运算符重载,使用windows命名规则程序规范

10、,可读性强,使用外部接口让程序更安全。缺点: 部分函数为类的友元函数,破坏了类的完整性。3.代码段:#include#includeusing namespace std; int gcd(int a, int b) ;class Rationpublic: Ration(int a = 0,int b = 0):numer(a),denom(b) void decide ();void trans (); void input (); friend Ration operator -(Ration c1,Ration c2); friend Ration operator +(Ration

11、c1,Ration c2);friend Ration operator *(Ration c1,Ration c2);friend Ration operator /(Ration c1,Ration c2);friend int gcd(int a, int b);friend istream & operator (istream &in,Ration &c );friend ostream & operator (ostream &out,Ration &c );private: int numer; int denom;void Ration : trans () /转变为小数 de

12、cide(); double c = (double)numer/(double)denom; cout 小数形式为 c endl;void Ration : decide() / 判别是否可以写成分数 if(0 = denom) cout (istream &in,Ration &c ) /c.decide(); coutc.numer; cin.get(); in c.denom; return in;ostream & operator (ostream &out,Ration &c ) /c.decide(); if(c.numer != 0) int GCD = gcd(c.nume

13、r,c.denom) ; if(GCD = 1) outc.numer/c.denom endl; else outc.numer/GCD/c.denom/GCDendl; else out0n; return out; int gcd(int a, int b) / 求最小公倍数 int n = b; int c = a % b; while(c!=0) a = b; b = c; c = a % b; return b; int main() Ration A; Ration B; Ration c; cout 请输入分数A A; cout 请输入分数B B; cout B = B; co

14、ut A = A; c = B / A; cout c = B / A = cendl; c = B * A; cout c = B * A = cendl; c = B + A; cout c = B + A = cendl; c = B - A; cout c = B - A = cendl; c.trans();return 0;4.程序截图:(三)、职工信息表设计。 使用继承的方法,编写最多能输入10个职工的信息表,再根据这个表产生一个职工信息简表,并利用多态性实现信息的输出。设计要求实现如下功能:1建立职工信息数据,包括职工编号、姓名,性别和年龄。2根据职工信息表,建立只含姓名和年龄

15、的职工信息简表。3使用继承的方法构造2个类,使用相应的对象数组放置10个职工信息。4编写同名display( )成员函数,用来输出数组的内容。5编写函数printer( ),用来根据实际对象输出它们的内容。1.流程图:2.程序优缺点:优点:使用windows命名规则程序规范,可读性强,代码精炼,时间复杂度低,空间复杂度低缺点: 功能较弱,操作性低。3.代码段:#include #include#includeusing namespace std; class Employee_one public: Employee_one(int n,char *nam,char s,int a):num

16、(n),name(nam),sex(s),age(a) virtual void display(); int getnum() return num; char* getname() return name; char getsex() return sex; int getage() return age; private: int num; char *name; char sex; int age; ; class Employee_two:public Employee_one public: Employee_two(int n,char* nam,char s,int a,int

17、 w):Employee_one(n,nam,s,a),wages(w) void display(); int getwages() return wages; private: int wages; ; void Employee_one:display() coutsetw(15)nname:name setw(15)setiosflags(ios:right) age:age setw(15)setiosflags(ios:left)sex:sexsetw(15) setiosflags(ios:left)num:num; void Employee_two : display() c

18、outname:getname()setw(15)age:getage()endl; /*nwages:wages*/; void printer(Employee_two w2) int a = 0,i = 0; couta; if(a = 10) for (i = 0;i 10;i+) if (w2i.getnum()=a) coutname:w2i.getname()nage:w2i.getage()nwages: w2i.getwages()nsex:w2i.getsex()nnum:w2i.getnum(); else cout编号错误差无此人; int main() Employe

19、e_one w110 = Employee_one(1,ci,m,18),Employee_one(2,cai,m,19), Employee_one(3,xi,f,18),Employee_one(4,su,m,20), Employee_one(5,li,m,20),Employee_one(6,yan,m,19), Employee_one(7,yi,m,18),Employee_one(8,xiu,m,21), Employee_one(9,su,m,17), Employee_one(10,men,m,22) ; Employee_two w210= Employee_two(1,c

20、i,m,18,800),Employee_two(2,cai,m,19,700), Employee_two(3,xi,f,18,900),Employee_two(4,su,m,20,750), Employee_two(5,li,m,20,860),Employee_two(6,yan,m,19,900), Employee_two(7,yi,m,18,1000),Employee_two(8,xiu,m,21,680), Employee_two(9,su,m,17,1500),Employee_two(10,men,m,22,700) ; cout职工信息数据显示如下:; for(in

21、t i = 0;i display(); cout n; coutn; cout职工信息简表如下:n; for(int j = 0;j display(); coutn; cout实际对象信息为:n; printer(w2); coutn; return 0; 4.程序截图:(四).高校人事管理系统:1、问题描述(功能要求): 某高校,主要人员有:在职人员(行政人员、教师、双肩挑人员(注:教师编制,担任领导职务)、退休人员、返聘人员和临时工。现在,需要存储这些人员的人事档案信息:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来校时间。要求: 1) 添加删除功能:能根据学校人事的变动情况,添加删除记录;2) 查询功能:能根据编号和姓名进行查询;3) 编辑功能(高级):根据查询对相应的记录进行修改,并存储;4) 统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数、高学历高职称人数);5) 保存功能:能对输入的数据进行相应的存储,要求重载插入和提取符以完成数据的保存和打开。6) 人员

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

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