资源描述:
《华中科技大学标准C语言程序设计及应用习题答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第二章一.选择题1.C2.BD3.A4.A5.D6.C7.D8.C9.A10.D11.B12.D13.C14.D15.A16.B17.A18.B100011001111二.判断题1.错2.错3.错4.错三.填空题1.B662.n1=%dn2=%d3.0四.计算1(1)x
2、y=0x002f(2)x^y=0x0026(3)x&y=0x0009;(4)~x+~y=0xffc6(5)x<<=30x0068(6)y>>=40x00022(1)6(2)50(3)1(4)–16(5)1(6)203(1)0(2)1(3)1(4)4
3、(5)8(6)14(1)12(2)0(3)1(4)27(1)1(2)6(3)24(4)27(5)–295(1)0(2)1(3)1(4)–3(5)2五.程序分析题程序1b=20a=3600程序2第三章一.填空题1.s=62.963.(1)scanf("%c",&c);(2)c-32更好的答案:c-('a'-'A')2.1main(){inta,b;printf("pleaseinputa&b:");scanf("%d%d",&a,&b);printf("maxis%d",(a>b)?a:b);}2.2intmax(
4、intx,inty);main(){inta,b,c,max;printf("pleaseinputa&b&c:");scanf("%d%d%d",&a,&b,&c);max=a>b?a:b;max=c>max?c:max;printf("maxis%d",max);}2.3main(){inti=0,sum=0;while(i<=100){sum+=i;i++;}printf("1+2+3+......+100=%d",sum);}2.4main(){inti;inta=10,b=-3;intc;print
5、f("%6d%6d",a,b);for(i=2;i<10;i++){c=3*b+a;printf("%6d",c);a=b;b=c;}printf("");}2.5main(){inti;while(1){printf("pleaseinputadata(0:exit):");scanf("%d",&i);if(i==0)break;if(i%2==0)printf("thedata%disaevennumber.",i);elseprintf("thedata%disaoddnumber.",i);}}2.
6、6#includemain(){inti;inta=8,b=1;intsum=0;for(i=0;i<10;i++){b+=3;sum+=a;a+=b;printf("a%8db:%8d",a,b);}printf("TheSumOfIs:%d",sum);}2.7#includemain(){floatx,y;printf("pleaseinputx:");scanf("%f",&x);if(x<1.0)y=x;elseif(x<10)y=2*x-1;elsey=3*x-11
7、;printf("y=%f",y);}2.8#includemain(){longa,i,b,a1;while(1){printf("pleaseinputdata(1-99999):");scanf("%ld",&a);printf("a:%ld",a);if(a<=0
8、
9、a>=100000)break;i=0;a1=0;while(a!=0){b=a%10;printf("%8d",b);a/=10;i++;a1=a1*10+b;}printf("i:%lda1:%ld",i,a1)
10、;}}2.9#include#include#includemain(){inta,b,i,k=0;randomize();a=random(1001);/*createarandomdata(0-1000)*/for(i=0;i<20;i++){printf("pleaseguessanumber:");scanf("%d",&b);if(a>b){k++;printf("%d:Smaller,guessagain!",k);}elseif(a11、;printf("%d:Bigger,guessagain!",k);}else{printf("Youguessright,congraturation!");printf("Youhaveguessed%dtimes",k);break;}}if(k==20)printf("so