欢迎来到天天文库
浏览记录
ID:51253694
大小:152.50 KB
页数:57页
时间:2020-03-20
《c++面向对象程序设计课后习题答案(谭浩强版).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
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<usingnamespacest
2、d;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、udeusingnamespacestd;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);r4、eturn0;}voidsort(intx,inty,intz){inttemp;if(x>y){temp=x;x=y;y=temp;}//{}内3个语句的作用是将x和y的值互换)if(zusingnamespacestd;intmain(){intmax(inta,intb,5、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、;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);cout7、<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#include8、ing>usingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
3、udeusingnamespacestd;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);r
4、eturn0;}voidsort(intx,inty,intz){inttemp;if(x>y){temp=x;x=y;y=temp;}//{}内3个语句的作用是将x和y的值互换)if(zusingnamespacestd;intmain(){intmax(inta,intb,
5、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、;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);cout7、<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#include8、ing>usingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
6、;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);cout
7、<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#include8、ing>usingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
8、ing>usingnamespacestd;intmain(){strings1="week",s2="end";cout<<"s1="<
此文档下载收益归作者所有