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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(c面向对象程序设计课后习题答案及解析谭浩强版文档格式.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c面向对象程序设计课后习题答案及解析谭浩强版文档格式.docx

1、m) m=z; return(m); 8: #include b;a+byz; sort(x,y,z);void sort(int x, int y, int z) int temp; if (xy) temp=x;x=y;y=temp; / 内3个语句的作用是将x和y的值互换)x) coutz,xy else if (zy) cout else cout11:int max(int a,int b,int c=0);max(a,b,c)=max(a,b,c)max(a,b)=max(a,b)a) a=b; if(ca) a=c; return a;12: void change(int ,i

2、nt ); int a,b; if(ab) change(a,b);max=a min=bvoid change(int ,int ) int r1,r2,temp; temp=r1; r1=r2; r2=temp;13:void sort(int &,int &); int a,b,c,a1,b1,c1;Please enter 3 integers: a1=a;b1=b;c1=c; sort(a1,b1,c1); in sorted order is a1b1c1j) change(i,j); if (ik) change(i,k); if (jk) change(j,k);void ch

3、ange(int &x,int &y) int temp; temp=x; x=y; y=temp;14:string string s1=week,s2=ends1=s1s2=s2 s1=s1+s2;The new string is: 15: string str; int i,n; char temp;please input a string:str; n=str.size(); for(i=0;in/2;i+) temp=stri;stri=strn-i-1;strn-i-1=temp;strreturn 0; 16: int i; string str5=BASIC,CFORTRA

4、NPASCAL; void sort(string ); sort(str);the sorted strings :5;strivoid sort(string s)int i,j; string t; for (j=0;jsi+1) t=si;si=si+1;si+1=t; 17: long c5=10100,-123567, 1198783,-165654, 3456; int a5=1,9,0,23,-45; float b5=2.4, 7.6, 5.5, 6.6, -2.3 ; void sort(int );void sort(float ); void sort(long );

5、sort(a); sort(b); sort(c);void sort(int a)int i,j,t; if (aiai+1) t=ai;ai=ai+1;ai+1=t;the sorted numbers :aiendl void sort(long a) long t;void sort(float a) float t;18:template void sort(T a) int i,j,min; T t; min=i; for (j=i+1;j+) if(aminaj) min=j; t=ai; ai=amin; amin=t; int a5=1,9,0,23,-45;第二章1clas

6、s Time public: void set_time(); void show_time();private: /成员改为公用的 int hour; int minute; int sec; ;void Time:set_time() /在main函数之前定义hour;minute;sec;show_time() /在main函数之前定义hourminutesec void show_time(void) cout private:Time t; t.set_time(); t.show_time(); 3: void set_time(void); void show_time(void

7、);set_time(void)show_time(void)cout t.set_time();4:/xt2-4-1.cpp(main.cpp)#include xt2-4.hStudent stud; stud.set_value(); stud.display();/xt2-4-2.cpp(即student.cpp) /在此文件中进行函数的定义 /不要漏写此行void Student:display( ) coutnum:numname:namesex:sexnum;cinname;sex;5:/xt2-5-1.cpp(file1.cpp)xt2-5.h Array_max arrmax

8、; arrmax.set_value(); arrmax.max_value(); arrmax.show_value();/xt2-5-2.cpp(arraymax.cpp)void Array_max: int i; for (i=0;10;arrayi;max_value() int i; max=array0; for (i=1; if(arrayimax) max=arrayi;show_value()max6:解法一class Boxpublic: void get_value(); float volume(); void display(); public: float len

9、gh; float width; float height;void Box:get_value()please input lengh, width,height:lengh;width;height;float Box:volume() return(lengh*width*height);display()volume()Box box1,box2,box3; box1.get_value();volmue of bax1 is box1.display(); box2.get_value();volmue of bax2 is box2.display(); box3.get_valu

10、e();volmue of bax3 is box3.display();解法二: void volume(); float vol; vol=lengh*width*height;vol box1.volume(); box2.volume(); box3.volume();cout第三章2:class Date Date(int,int,int); Date(int,int); Date(int); Date(); int month; int day; int year;Date:Date(int m,int d,int y):month(m),day(d),year(y) Date(i

11、nt m,int d):month(m),day(d) year=2005;Date(int m):month(m) day=1; year=2005;Date() month=1; day=1;void Date:month/dayyear Date d1(10,13,2005); Date d2(12,30); Date d3(10); Date d4; d1.display(); d2.display(); d3.display(); d4.display();3: Date(int=1,int=1,int=2005);4:class Student Student(int n,float s):num(n),score(s) int num; float score;scoredisplay();usi

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

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