网站大量收购独家精品文档,联系QQ:2885784924

面向对象程序设计期末综合练习4(运行结果含答案).doc

面向对象程序设计期末综合练习4(运行结果含答案).doc

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

PAGE  PAGE 26 面向对象程序设计期末综合练习四(运行结果) 写出程序运行结果 1. #includeiostream.h #includestdlib.h void main() { int a[8]={25,48,32,85,64,18,48,29}; int max,min; max=min=a[0]; for(int i=0; i8; i++) { if(xa[i]) max=a[i]; if(xa[i]) min=a[i]; } coutmax:maxendl; coutmin:minendl; } 2. #includeiostream.h void main() { int a,b; for(a=1,b=2; b50;) { couta b ; a=a+b; b=a+b; } coutendl; couta b endl; } 3. #includeiostream.h const int M=3, N=4; void main() { int i,j,s=0; for(i=1;i=M;i++) for(j=1;j=N;j++) s+=i*j; cout”s=”sendl; } 4. #includeiostream.h void main() { int a=2,b=5,c=0; if(a+b10) c=a*b; else c=3*a+b; if(c=20) coutc*c; else cout4+c-5; coutendl; a=a+b; b=a+b;c+=a+b; couta,b,c=a,b,cendl; } 5. #includeiostream.h void main() { int x=5; switch(2*x-3) { case 4: coutx’ ’; case 7: cout2*x+1’ ’; case 10: cout3*x-1’ ’; break; default: coutdefaultendl; } coutswitch end.endl; } 6. #includeiomanip.h #includemath.h int a[4]={36,-5,73,8}; void main() { int i,y; for(i=0; i4; i++) { if(a[i]0) y=1; else if(a[i]10) y= a[i]* a[i]+3; else if(a[i]60) y=4*a[i]-5; else y=int(sqrt(a[i])); // sqrt(x)为取x的平方根函数 coutsetw(5)a[i]setw(5)y; } } 7. #includeiostream.h int a[8]={36,25,20,43,12,70,66,35}; void main() { int s0,s1,s2; s0=s1=s2=0; for(int i=0; i8; i++) { switch(a[i]%3) { case 0: s0+=a[i];break; case 1: s1+=a[i];break;

文档评论(0)

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

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

1亿VIP精品文档

相关文档