C++程序设计教程 第一版 (龚沛曾 杨志强 著) 高等教育出版社 课后答案 第三章 结构化程序设计 课后答案.docVIP

  • 18
  • 0
  • 约2.98千字
  • 约 12页
  • 2018-05-28 发布于河南
  • 举报

C++程序设计教程 第一版 (龚沛曾 杨志强 著) 高等教育出版社 课后答案 第三章 结构化程序设计 课后答案.doc

C程序设计教程第一版(龚沛曾杨志强著)高等教育出版社课后答案第三章结构化程序设计课后答案

C++程序设计教程 第一版 (龚沛曾 杨志强 著) 高等教育出版社 课后答案 第三章 结构化程序设计 课后答案 第三章 结构化程序设计 一、 选择题 1-2CD 第3题:75其他值 4-9CBCACB 二、 阅读程序,写出运行结果 1、输入两个正数 2、count=20,m=101 3、s=288 4、AB20ega5 m5、注:︺表示空格 ︺︺︺︺︺︺︺︺︺ ︺︺︺︺︺︺︺︺*︺ o︺︺︺︺︺︺︺*︺*︺ ︺︺︺︺︺︺*︺*︺*︺ c 三、 程序填空 1、c==) count==0 count0 -count 2、cinmn m=m-n n=n-m 网 3、n=m n=n/5 m=m+5 . 案 w 四、 编程题 答 1、 #includeiostream.h 后 #includemath.h a voidmain() 课 { d doublex,y; coutpleaseinputx:; h cinx; if(x5)fabs(x); k elseif(x20) y=3*x*x-2*x-1; else y=x/5; couty=yendl; } w 2、 #includeiostream.h voidmain() { floats,p,s1,s2; coutenterwages:; cins; switch(int(s/1000)) { case0:p=0;break; case1:p=0.05;break; case2:p=0.08;break; case3: case4:p=0.10;break; default:p=0.15; } m s1=s*p;s2=s-s1; cout纳税款为:s1endl; cout实得工资为:s2endl; o} c 3、 #includeiostream.h voidmain() 网 { . inti,x,y,z,count=0; 案 for(i=100;i1000;i++) 答 w { x=i%10; 后 y=i/10%10; a z=i/100; 课 if(x+y+z==5) d { count++; h couti; } } k coutendl; cout一共有count个整数,其各个数位数字之和等于5endl; } 4、 w #includeiostream.h voidmain() { inti,j; for(i=0;i=30;i++) { j=30-i; if(2*i+4*j==90) cout鸡和兔的个数分别为:i,jendl; } } 5、 #includeiostream.h #includemath.h #includeiomanip.h voidmain() { doublepi=0,//表示Pi值,初值为0 m t=1,//t表示当前项,初值为1 p=1,//表示当前项的符号项,初值为正 i=1;//当前项的绝对值的分母,初值为1 o do { c pi=pi+t; i=i+2; p=(-1)*p; 网 t=p/i; . }while(fabs(t)=1E-4); 案 pi=4*pi; 答 w coutpi≈setiosflags(ios::fixed)setprecision(8)piendl; } 后 课 a 6、 d #includeiostream.h voidmain() h { int(x,y;;x=100;x++) k for(y=1;y=100;y++) if(x*x+2+x==y*y*y) coutx,yendl; } w 7、 #includeiostream usingnamespacestd; voidmain() { charc; coutenteronesentence:; while((c=getchar())

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档