欢迎来到天天文库
浏览记录
ID:18974908
大小:240.00 KB
页数:123页
时间:2018-09-27
《c++面向对象程序设计(谭浩强_编著)习题程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、XT1-5.CPP、(第一章的第五题,下面类似)#includeusingnamespacestd;intmain(){intsum;for(inti=0;i<6;i=+3){sum=i;for(intj=i;j<6;j++)sum+=j;}cout<<"sum="<usingnamespacestd;intmain(){inta,b,c;a=10;b=23;c=a+b;cout<<"a+b=";cout<2、turn0;}XT1-7.CPP#includeusingnamespacestd;intmain(){inta,b,c;intf(intx,inty,intz);cin>>a>>b>>c;c=f(a,b,c);cout<usingnamespacestd;intmain(){inta,b,c;ci3、n>>a>>b;c=a+b;cout<<"a+b="<usingnamespacestd;intmain(){intadd(intx,inty);inta,b,c;cin>>a>>b;c=add(a,b);cout<<"a+b="<usingnamespacestd;intma4、in(){voidsort(intx,inty,intz);intx,y,z;cin>>x>>y>>z;sort(x,y,z);return0;}voidsort(intx,inty,intz){inttemp;if(x>y){temp=x;x=y;y=temp;}//{}内3个语句的作用是将x和y的值互换)if(z5、11.CPP#includeusingnamespacestd;intmain(){intmax(inta,intb,intc=0);inta,b,c;cin>>a>>b>>c;cout<<"max(a,b,c)="<a)a=b;if(c>a)a=c;returna;}XT1-12.CPP#includeusingnames6、pacestd;intmain(){voidchange(int&,int&);inta,b;cin>>a>>b;if(ausingnamespacestd;intmain(){voidsort(int&,i7、nt&,int&);inta,b,c,a1,b1,c1;cout<<"Pleaseenter3integers:";cin>>a>>b>>c;a1=a;b1=b;c1=c;sort(a1,b1,c1);cout<j)change(i,j);if(i>k)change(i,k);if8、(j>k)change(j,k);}voidchange(int&x,int&y){inttemp;temp=x;x=y;y=temp;}XT1-14.CPP#include
2、turn0;}XT1-7.CPP#includeusingnamespacestd;intmain(){inta,b,c;intf(intx,inty,intz);cin>>a>>b>>c;c=f(a,b,c);cout<usingnamespacestd;intmain(){inta,b,c;ci
3、n>>a>>b;c=a+b;cout<<"a+b="<usingnamespacestd;intmain(){intadd(intx,inty);inta,b,c;cin>>a>>b;c=add(a,b);cout<<"a+b="<usingnamespacestd;intma
4、in(){voidsort(intx,inty,intz);intx,y,z;cin>>x>>y>>z;sort(x,y,z);return0;}voidsort(intx,inty,intz){inttemp;if(x>y){temp=x;x=y;y=temp;}//{}内3个语句的作用是将x和y的值互换)if(z5、11.CPP#includeusingnamespacestd;intmain(){intmax(inta,intb,intc=0);inta,b,c;cin>>a>>b>>c;cout<<"max(a,b,c)="<a)a=b;if(c>a)a=c;returna;}XT1-12.CPP#includeusingnames6、pacestd;intmain(){voidchange(int&,int&);inta,b;cin>>a>>b;if(ausingnamespacestd;intmain(){voidsort(int&,i7、nt&,int&);inta,b,c,a1,b1,c1;cout<<"Pleaseenter3integers:";cin>>a>>b>>c;a1=a;b1=b;c1=c;sort(a1,b1,c1);cout<j)change(i,j);if(i>k)change(i,k);if8、(j>k)change(j,k);}voidchange(int&x,int&y){inttemp;temp=x;x=y;y=temp;}XT1-14.CPP#include
5、11.CPP#includeusingnamespacestd;intmain(){intmax(inta,intb,intc=0);inta,b,c;cin>>a>>b>>c;cout<<"max(a,b,c)="<a)a=b;if(c>a)a=c;returna;}XT1-12.CPP#includeusingnames
6、pacestd;intmain(){voidchange(int&,int&);inta,b;cin>>a>>b;if(ausingnamespacestd;intmain(){voidsort(int&,i
7、nt&,int&);inta,b,c,a1,b1,c1;cout<<"Pleaseenter3integers:";cin>>a>>b>>c;a1=a;b1=b;c1=c;sort(a1,b1,c1);cout<j)change(i,j);if(i>k)change(i,k);if
8、(j>k)change(j,k);}voidchange(int&x,int&y){inttemp;temp=x;x=y;y=temp;}XT1-14.CPP#include
此文档下载收益归作者所有