同济大学c实验1到实验8前三题.docx

  1. 1、本文档共45页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # 实验4: 1. #i nclude “ / void mai n() {int n, sum=0; for(n=1;;sum+=n,n+=2) if(n=20) break; coutvv sum=vvsumvvendl; } 2. #i nclude “ void mai n() {int x; coutvv input x: vvendl; cin x; if(x==0) coutvv 0; else while(x!=0) {coutvvx%10; x=x/10; } 百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # coutvve ndl; } 3. #i nclude “ void mai n() {int i,t=1; float s=0; for(i=1;t1e-4;i++) {s=s+t; t=t+i; } cout ”s= ”wswendl; } 4. #i nclude “ void mai n() {double pi=1,t=2; int n; for(n=1;t1e-4 ;n++) {pi=pi*t; t=(float)((2* n)*(2* n) )/((2* n-1)*(2* n+1)); 百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # } coutvv ”pi= ” vvpivvendl; } 5. (1) #i nclude “ #i nclude “ void mai n() {int i,j; for(i=1;iv=9;i++) { coutvvsetw(20-i); for(j=1;jv=2*i-1;j++) coutvvi; coutvve ndl; } } 5. (2) TOC \o 1-5 \h \z #i nclude “ #i nclude “ void mai n() {int i,j; char c; for(i=9;i=1;i - { coutvvsetw(9-i)vv ” 百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # c=9-i+ A: for(j=1;jv=2*i;j++) coutvvc; coutvve ndl; } } 6. #i nclude “ void mai n() {int m,m1,m2,m3; for(m=100;mv1000;m++) {m1=m%10; m2=m/10%10; m3=m/100; if(m1*m1*m1+m2*m2*m2+m3*m3*m3==m) coutvvmvv\t ”; } } 7. #i nclude “ #i nclude “ void mai n() 百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # {int x,y,z,k=O; for(x=1;xv=6;x++) for(y=x+1;yv=6;y++) for(z=5;z=6;z++) if(xy yz) { k++; coutvvxvv vvyvv vvzvvendl; } coutvv 满足条件的方案有:vvkvvendl; } 8. TOC \o 1-5 \h \z #i nclude “ #i nclude “ #i nclude “ void mai n() {int a,n ,i,k; double s=0,temp=0; sra nd(time(NULL)); a=ra nd()%9+1; n=ra nd()%6+5; for(i=1;i=n ;i++) {temp=temp*10+a; s=s+temp; 百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # } coutvv ”= ”vvsvvendl; } 9. #i nclude “ #i nclude “ void mai n() {float a,x,x1; cin a; x=a; do {x1=x; x=3*x+a/(3*x*x); }while(fabs(x-x1)1e-5); coutvv 编程求得 x= vvxvvendl; coutvv 调用函数求得 x=vvpow(a,3)vvendl; } 实验5: #i nclude “ #i nclude “ 百度文库- 百度文库-让每个人平等地提升自我 PAGE PAGE # void mai n() {int a[10],i,max, min; float ave; for(i=0;i10;i++) a[i]=ra nd()%71+30; coutvv 数组a的内容如下:\n ” for(i

文档评论(0)

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

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

1亿VIP精品文档

相关文档