欢迎来到天天文库
浏览记录
ID:13900346
大小:305.00 KB
页数:57页
时间:2018-07-24
《c++面向对象程序设计课后习题答案(谭浩强版)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第一章5:#includeusingnamespacestd;intmain(){cout<<"This"<<"is";cout<<"a"<<"C++";cout<<"program."<usingnamespacestd;intmain(){inta,b,c;a=10;b=23;c=a+b;cout<<"a+b=";cout<usingnamespaces
2、td;intmain(){inta,b,c;intf(intx,inty,intz);cin>>a>>b>>c;c=f(a,b,c);cout<usingnamespacestd;intmain(){inta,b,c;cin>>a>>b;c=a+b;cout<<"a+b="<3、cludeusingnamespacestd;intmain(){intadd(intx,inty);inta,b,c;cin>>a>>b;c=add(a,b);cout<<"a+b="<usingnamespacestd;intmain(){voidsort(intx,inty,intz);intx,y,z;cin>>x>>y>>z;sort(x,y,z4、);return0;}voidsort(intx,inty,intz){inttemp;if(x>y){temp=x;x=y;y=temp;}//{}内3个语句的作用是将x和y的值互换)if(zusingnamespacestd;intmain(){intmax(inta,i5、ntb,intc=0);inta,b,c;cin>>a>>b>>c;cout<<"max(a,b,c)="<a)a=b;if(c>a)a=c;returna;}12:#includeusingnamespacestd;intmain(){voidchange(int,int);inta,b;cin>>a>>b;if(a6、(a,b);cout<<"max="<usingnamespacestd;intmain(){voidsort(int&,int&,int&);inta,b,c,a1,b1,c1;cout<<"Pleaseenter3integers:";cin>>a>>b>>c;a1=a;b1=b;c1=c;sort(a1,b1,c17、);cout<j)change(i,j);if(i>k)change(i,k);if(j>k)change(j,k);}voidchange(int&x,int&y){inttemp;temp=x;x=y;y=temp;}14:#include#incl8、udeusingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
3、cludeusingnamespacestd;intmain(){intadd(intx,inty);inta,b,c;cin>>a>>b;c=add(a,b);cout<<"a+b="<usingnamespacestd;intmain(){voidsort(intx,inty,intz);intx,y,z;cin>>x>>y>>z;sort(x,y,z
4、);return0;}voidsort(intx,inty,intz){inttemp;if(x>y){temp=x;x=y;y=temp;}//{}内3个语句的作用是将x和y的值互换)if(zusingnamespacestd;intmain(){intmax(inta,i
5、ntb,intc=0);inta,b,c;cin>>a>>b>>c;cout<<"max(a,b,c)="<a)a=b;if(c>a)a=c;returna;}12:#includeusingnamespacestd;intmain(){voidchange(int,int);inta,b;cin>>a>>b;if(a6、(a,b);cout<<"max="<usingnamespacestd;intmain(){voidsort(int&,int&,int&);inta,b,c,a1,b1,c1;cout<<"Pleaseenter3integers:";cin>>a>>b>>c;a1=a;b1=b;c1=c;sort(a1,b1,c17、);cout<j)change(i,j);if(i>k)change(i,k);if(j>k)change(j,k);}voidchange(int&x,int&y){inttemp;temp=x;x=y;y=temp;}14:#include#incl8、udeusingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
6、(a,b);cout<<"max="<usingnamespacestd;intmain(){voidsort(int&,int&,int&);inta,b,c,a1,b1,c1;cout<<"Pleaseenter3integers:";cin>>a>>b>>c;a1=a;b1=b;c1=c;sort(a1,b1,c1
7、);cout<j)change(i,j);if(i>k)change(i,k);if(j>k)change(j,k);}voidchange(int&x,int&y){inttemp;temp=x;x=y;y=temp;}14:#include#incl
8、udeusingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
此文档下载收益归作者所有