资源描述:
《《程序设计技术》习题参考答案(修改).doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、《程序设计技术》(第三版)习题参考答案习题1一、单项选择题DADDDBDCCD二、填空题①主②main③x=x*(x+b)④普通、格式、分隔和转义⑤指定输出数据格式⑥voidmain()⑦"howareyou!"三、阅读程序题1.9,11,9,102.2,-1,-23.aabbccabcAN4.2,25.575767.5864000,-789.12402367.5864000,-7.89e+00267,86,-789.12,67.5864000,-789.124023,67.5864000,-789.1240236.758640e+0
2、01,-7.89e+002A,65,101,411234567,4553207,12d68765535,177777,ffff,65535COMPUTER,COM.6.a+c=102a+c=ff+m=17.950000a+m=17.650000c+f=102.300000double=1746.150019四、程序设计题//xt010401.cpp#include#definePI3.1415926voidmain(){doubler,h;printf("请输入半径r和高h:");scanf("%lf,%lf",&r
3、,&h);printf("圆半径:%lf",2*PI*r);printf("圆面积:%lf",PI*r*r);printf("圆球表面积:%lf",4*PI*r*r);printf("圆球体积:%lf",4.0/3*PI*r*r);printf("圆柱体积:%lf",PI*r*r*h);}//xt010402.cpp#includevoidmain(){intc;printf("Inputacharacter:");c=getchar();printf("%ct%d",c,c);}//xt0
4、10403.cpp#includevoidmain(){intx,y,h=30,f=90;x=(4*h-f)/2;y=(f-2*h)/2;printf("鸡:%d,兔:%d",x,y);}//xt010404.cpp#include#includevoidmain(){doublea,b,c,s,area;printf("请输入三角形的三条边长(注意三条边长应能够构成三角形):");scanf("%lf,%lf,%lf",&a,&b,&c);s=(a+b+c)/2;area=sq
5、rt(s*(s-a)*(s-b)*(s-c));printf("三角形的面积是:%lf",area);}//xt010405.cpp#includevoidmain(){doublef,c;printf("请输入华氏温度:");scanf("%lf",&f);c=5.0/9.0*(f-32);printf("与华氏温度%.2lf对应的摄氏温度是:%.2lf",f,c);}//xt010406.cpp#includevoidmain(){charc1,c2,c3,c4,c5;printf("请
6、输入需加密的字符串(5个字符):");c1=getchar();c2=getchar();c3=getchar();c4=getchar();c5=getchar();printf("加密后的字符串是:");putchar(c1+5);putchar(c2+5);putchar(c3+5);putchar(c4+5);putchar(c5+5);printf("");}习题2一、单项选择题CBADCCCAAC二、填空题①a+b==0&&a*b!=0②逻辑与③逻辑或④continue⑤(c=getchar())!=''⑥%c三、
7、阅读程序题答案:答案:该程序所完成功能的函数关系为:答案:答案:答案:答案:四、程序设计题/*xt020401.cpp*/#includevoidmain(){intnum;printf("****Inputnum:****");scanf("%d",&num);if(num%3==0&&num%5==0&&num%7==0)printf("**YES!**");elseprintf("**NO!**");}/*xt020402.cpp*/#includevoidmain(){inth=
8、0;floatx,y,x0=2,y0=2,d1,d2,d3,d4;printf("***input:x,y***");scanf("%f,%f",&x,&y);d1=(x-x0)*(x-x0)+(y-y0)*(y-y