c++糜腈向对象程序设计课后习题答案(谭浩强版).doc

c++糜腈向对象程序设计课后习题答案(谭浩强版).doc

  1. 1、本文档共57页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
c糜腈向对象程序设计课后习题答案(谭浩强版)

第一章 5: #include iostream using namespace std; int main() { coutThisis; coutaC++; coutprogram.endl; return 0; } 6: #include iostream using namespace std; int main() { int a,b,c; a=10; b=23; c=a+b; couta+b=; coutc; coutendl; return 0; } 7: #include iostream using namespace std; int main() { int a,b,c; int f(int x,int y,int z); cinabc; c=f(a,b,c); coutcendl; return 0; } int f(int x,int y,int z) { int m; if (xy) m=x; else m=y; if (zm) m=z; return(m); } 8: #include iostream using namespace std; int main() { int a,b,c; cinab; c=a+b; couta+b=a+bendl; return 0; } 9: #include iostream using namespace std; int main() {int add(int x,int y); int a,b,c; cinab; c=add(a,b); couta+b=cendl; return 0; } int add(int x,int y) {int c; c=x+y; return(c); } 10: #include iostream using namespace std; int main() {void sort(int x,int y,int z); int x,y,z; cinxyz; sort(x,y,z); return 0; } void sort(int x, int y, int z) { int temp; if (xy) {temp=x;x=y;y=temp;} //{ }内3个语句的作用是将x和y的值互换) if (zx) coutz,x,yendl; else if (zy) coutx,z,yendl; else coutx,y,zendl; } 11: #include iostream using namespace std; int main() {int max(int a,int b,int c=0); int a,b,c; cinabc; coutmax(a,b,c)=max(a,b,c)endl; coutmax(a,b)=max(a,b)endl; return 0; } int max(int a,int b,int c) {if(ba) a=b; if(ca) a=c; return a; } 12: #include iostream using namespace std; int main() { void change(int ,int ); int a,b; cinab; if(ab) change(a,b); coutmax=a min=bendl; return 0; } void change(int ,int ) { int r1,r2,temp; temp=r1; r1=r2; r2=temp; } 13: #include iostream using namespace std; int main() {void sort(int ,int ,int ); int a,b,c,a1,b1,c1; coutPlease enter 3 integers:; cinabc; a1=a;b1=b;c1=c; sort(a1,b1,c1); couta b c in sorted order is ; couta1 b1 c1endl; return 0; } void sort(int i,int j,int k) { void change(int ,int ); if (ij) change(i,j); if (ik) change(i,k); if (jk) change(j,k); } void change(int x,int y) { in

文档评论(0)

junzilan11 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档