新概念C语言能力教程练习试题04答案

新概念C语言能力教程练习试题04答案

ID:83426987

大小:1.69 MB

页数:23页

时间:2023-04-26

上传者:无敌小子
新概念C语言能力教程练习试题04答案_第1页
新概念C语言能力教程练习试题04答案_第2页
新概念C语言能力教程练习试题04答案_第3页
新概念C语言能力教程练习试题04答案_第4页
新概念C语言能力教程练习试题04答案_第5页
新概念C语言能力教程练习试题04答案_第6页
新概念C语言能力教程练习试题04答案_第7页
新概念C语言能力教程练习试题04答案_第8页
新概念C语言能力教程练习试题04答案_第9页
新概念C语言能力教程练习试题04答案_第10页
资源描述:

《新概念C语言能力教程练习试题04答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

44.1C“”“Ꮇ”Ḅṹᨵᱯe᦮ee!=1ᔩe==0ᔩC“”“Ꮇ”Ḅṹᓫᙢ!0⊤#“Ꮇ”$0%⊤“”஺ᙠ()*+,᝞.0⊤#“Ꮇ”$0%⊤“”஺/0◤23ᙠ⊤#()*+45,“Ꮇ”0,“”1஺6e0,eḄ718e!=1Ḅ7086==0Ḅ71஺6e$0,eḄ708e!=1Ḅ79:e/;0?e==0Ḅ70,;e$0,!eḄ7<0஺e==0Ḅ71,e0,!eḄ7<1஺ABᡠD!ee!=1/e==0஺4.2EF()ᡈ||()$Ḅ7⊤஺()ᡈIIḄ7⊤aḄ7bḄ7a||bḄ7I$0=I$0=1=I$0=ᎷI0I1=Ꮇ(0)I$0=(1)Ꮇ(0)ᎷI0Ꮇ(0)()$Ḅ7⊤aḄ7!aḄ7I$0Ꮇ(0)

1Ꮇ(0)(1)4.31.a*b>c&&a+b<=c2.a+b>c|a+bc)-15.a>bb||c=a7.a>0&&(x=b||1)8.!(x=c)IIa==b-11.a*b>cḄ7a+b<=cḄ7ᦑf⊤gh஺2.a+b>cḄ7Ꮇ,a+bc)-1Ꮇᦑf⊤ghᎷ஺5.a>bḄ7Ꮇ(0),0bᎷc=aḄ7ᦑf⊤gh஺7.a>0Ḅ7(x=b|1)Ḅ7ᦑf⊤gh஺8.!(x=c)Ḅ7Ꮇa==b-1Ḅ7ᦑf⊤gh஺4.4ᑏFl☢4nḄC⊤gh஺1.pqra,b,cḄpstuvspst஺2.a,b,cpw᦮ᦪbᨬᜧ஺3.a,b,cpw᦮ᦪ{|ᨵ}wu~ᦪ஺4.a,b,cpw᦮ᦪᨵ}wu~ᦪ஺5.chᜧ஺6.xḄ7ᙠ1,10ᡈ(23,72o7.lீx<3ᡈx<0஺8.x7ᦪf(x)=~~2Ḅ஺x1.a*a+b*b==c*c||a*a+c*c==b*b|b*b+c*c==a*a2.b>a&&b>c3.a<0&&b<0||a<0&&c<0||b<0&&c<0

24.a<0&&b<0&&c>=0||a<0&&c<0&&b>=0||b<0&&c<0&&a>=05.chு='A'&&ch<=ஹZ'6.x>=1&&x<=10||x>23&&x<=727.x>l&&x<3||x<08.(x>=2I|x<=1)&&x!=04.5ᵨ}ᩩx<0&&(x=-x);printfC,%f

3H,x);9FxḄ7ᔩ᝞᪵Ḅ9/09ឋ¡!1ttinclude2uoidmain()3floatx;5scanfW,&x);6x2voidma±n()34i1=(-d♦Fu==8)5p^intF("--I*1©

4");6else7pr-±ntF('---I♦1U/;:8iF<-2*1u>0)9pr-intF(;FOeXse-I-I-2*-|u);12iF(-3*-1u>O)13pr-intF(,else15pt-±ntF(,Rx;042949672943.13Ifᫀµ¶ᵨif4᪀£¤·=

51^include2uoidmain()3unsignedshortui=3,uj=5;5if(ui-uj>0)6printF("%u,%hu

6",ui-uj,ui-uj);7iF(ui-uj<=0)8printf("%d,%hd

7",ui-uj,ui-uj);93.18ttinclude2uoidmain()3<4intn,i,j,k;5printF(“ᐭᦪḄ᦮ᦪ

8“);6scanf(■"%(!",&n);7if(*(n>99&&n<1800))89printfC,ᐭ┯⌨n“)10return;11121314151617.11819printf,Ḅᦪd

9”,n);20ᐭᦪḄ6789ᐭ┯⌨13.21if(!(c>=¸&&c<=*y1))(printf(஻ᐭ┯»©ª⌨F

10஻)8return;)3.25if(!(fa+fb>fc&&fa+fc>fb&&fc+fb>fa))

11printfI஻ᐭ┯»pq/:᪀ᡂÃwpst©ª⌨F

12஻=8return;=4.7ᐭÃwÆᑏÇÈÉÊË3wÌÍÊF஺᝞Îᡂd,yᡂÑ஺Iᵨif4᪀ÒÓÔ$⊤ghIIch+3-'a'=%26+Ö=1ttinclude2uoidmain()34charch"5printf(”ᐭᑏ

13”);6ch=getchar();1iF(?(ch>='a'&&ch<='z*))89printf("ᐭ┯⌨n“);10return;11>12ch+=3;13iF(ch>'z')14putchar(ch-26);15else16putchar(ch);17ᐭ"#ᐭᑏaydb4.8×Fl☢©ªḄØ©Ù஺©ªᨵÚᩩ9᡻ÜÝÞßᩩ9᡻ÜÝÞᑖáâãä᪵Ḅᐭᦪ®^includevoidmain()(intx,y,z=0;scanf(n%d%d"&x,&y);zif(x>0)z=x+y;if(y>0)z=x-y;printf("x=%dy=%d,z=%d

14u,x,y,z);z

159婪ᨵ4ᩩ9᡻ÜÝÞ஺æÃᩩx>0çy>0,©ªḄ᡻ÜÝÞI᝞ᐭᦪ®2ஹ3,=8æèᩩx>0çy<=0,©ªḄ᡻ÜÝÞI᝞ᐭᦪ®2ஹ-5,=8æpᩩx<=0çy>0,©ªḄ᡻ÜÝÞI᝞ᐭᦪ®-2ஹ5,=8æéᩩx<=0çy<=0,©ªḄ᡻ÜÝÞI᝞ᐭᦪ®-2ஹ-5,=஺᝞5ê⌱ì4᪀Ḅᑖáᦋzl=x+y;z2=x-y;,ᑣð0FprintfI"x=%d,y=%d,zl=%d,z2=%d

16",x,y,zl,z2=;9:òóôᨎᙢ⊤öᐸᨵéᩩ9᡻ÜÝÞ஺ø4-9úᯠᨵpwif⌱ì4᪀ü6æÃwif⌱ì4᪀Ḅᩩý,ᐸþ}wif⌱ì4᪀ḄᩩýÿᎷᓽif⌱᪀Ḅᩩᨵᐵὶឋ஺4.9ᑖ᪆☢Ḅ஺1Ḅ"!523%ᐭ'()”+“!-523%ᐭ┯/,⌨)”!2%34ᑖ567⚪Ḅ6ᶭ᝕;<ᔡ>

17?4-11Ḅ:(3)᝞Bif⌱᪀CDᨵreturnEFᑣH☢ḄCEFᙳJᳮLif⌱᪀ᩩᎷM◤᡻PḄEFᓽQRSif-elseCelseTᑖ஺4.10ᐭ᦮ᦪx+y,Wx'y2ᜧS100,ᑣx?+y2YZ[\Ḅᦪ]ᔲᑣ_ᦪ`+஺a:

18ttincludeuoidmain()100)z/=100elsez=x+y;printf("%d

19",z);>ᐭ$᦮ᦪ:-5914.11ᨵcdᦪ:x(x<2)y=<2x-l(2^x<17)ஹsin(x)+l(x^l7)rᐭxMys;⌕v6w᯿?4T6ᵨ_|}~34஺a:1ttinclude2ttinclude3uoidnain()4<5Floatx,y;6scanFC'V",&x);1if(x<2)8y=x;9else10if(x<17)11y=2*x-1;12else13y=sin(x)+1;14printF("x=%F,y=%F

20",x,y);15

21ttincludettincludeuoidnain()=2)y=2*x-1;>elsey=sin(x)♦1;printF("x=%F,y=%F

22",x,p);34ᶍ஺4.12ᐭc]᝞Bᜧᑏ]ᑣᑏ᝞Bᑏ]ᑣᜧᑏ;ᐸH]᪵஺!ᑖ5ᵨif᪀+if-else᪀%a6if-else᪀2uoidmain()3charca;5ca=getchar();6if(ca>='a'&&ca<=•z')7ca-='a'—,A';8if(ca>=•A'&&ca<=Z)9ca+=*a'-,A';10putchar(ca);

23'(Ḅif᪀:/includeuoidmain()charca;intFlag=0;ca=getchar();iF(ca>='a'&&ca<="z')ca-='a'—A'Flag=1;>if(Flag==0&&(ca>='A'&&ca<=,Z'))ca+='a'-'A";putchar(ca);inᐭ•ᡫinclude2uoidmain()3="a'&&ca<='z')8cb-='a'—"A';9if(ca>='A"&&ca<=Z)10cb+='a'-'A";11putchar(cb);124.13[ᵨSx,y,zCḄᨬᜧsᙠᑜ\ᐭ'(ᑁ஺#includevoidmain()(intx=12,y=5,z=8;intmax;max=x

24"max

25a6?4T3J[ᦋᑏ1^include2uoidnain()3<4Floatx,y;5scanFC'^W,&x,&y);6if(x>y)7(^11*(”ᓾ:,ᢥᓣṃ1ᓾ:,ḕ111“'x,y,y,x);8iF(?(x>y))9ᢥᓣ2,3f

26“x,y,x,y);10?4-21J[ᦋᑏ1Itinclude2uoidmain()3(4intyear,leap;5scanf("^d",&year);6iF(year4?=0)7leap=0;8“(year%4==஺&&year%100?=0)//if

27”,year);16“(leap30)17print"”,

28”year);18ᡈὅᦋᑏ1ttinclude2uoidnain()3<4intyear,leap;5scanF("^d",ftyear);6if((year%4==0&&year%100?=O)||year%400==0)7leap=1;8if(?((year%4==O&&year%160♦=O)||year%406==O))9leap=0;10if(leap==1)11printf("■5675n“,year);12if(leap==0)13printf(Rd58675n“year);144.15☢Ḅdᦪ!x᦮%ᙠᑜ\ᐭ'(Ḅᑁ஺

29(0Wx<10)10(10^x<30)y=<30-0.5x(30—ஹ50(x250)#includevoidmain()(intx,ifloaty;scanf(,&x)if()i=5;elsei=;switch(i)(case0:y=xbreak;case1:case2:y=10;break;case3:case4:y=30-0.5*break;case5:y=50;break;default:y=-1;break;)if()printf("y=%3.lf

30",y)elseprintf("ᐭ┯/)

31"))a6x>=50i/10

32y!=-14.16ᵨbreakEF⌨switch᪀£¤᝞¥᡻Pᕖ§ᑖ᪆☢Ḅ஺#includevoidmain()(inta=2,b=3;switch(a>0)(case1:switch(b<0)(default:printf("case1:default

33");case1:printf("case1:casel

34H);break;case2:printf("case1:case2

35");break;}case2:printf(ncase2:

36");default:printf("default!

37”);break;case0:printf("case0:

38");)printf(Ha=%d,b=a,b);)a6Ḅ᡻PB6case1defaultbase1case1case2default?a=2,b=3Cswitch⌱᪀C¨ᝅswitch⌱᪀ª«ᑖ᪆Ḅ᡻PBJ[¬breakEF®¯°±H²SḄ³switch⌱᪀஺switch⌱᪀᡻P´µ¶ᯠ<᡻P¸¹H☢ḄCEF஺4.17if-else᪀J[ᵨswitch᪀ᦋᑏᔩ§a6J[«if-else᪀»¼⌕ᦋᑏᡂswitch᪀ᕖ§

39if!⊤¿À%EF1;elseEF2;ÂÃḄswitch᪀6switch!⊤¿À%!case1:EF1break;case0:EF2;break;}4.18᦮ÎÏxÐ]ÎÏyᨵ᝞ÑÒᐵÓ஺Xyx/100100

401ttinclude2uoidmain()3{4intx9i;5chary;6scanFC%d",&x);78if(x>1008)9i=10;10else11i=(x-1)/100;12switch(i)13<14case1:15y="A';16break;17case2:18case3:19case4:20y="B'21break;22case5:23case6:24case1:25case8:26case9:27y='C;28break;29case10:30y='D';31break;32deFault:33y='E'34>35if(y=='E')36printf("(2d)ᐭ┯37else38printF("F(%d)=%c

41",x39>4.19ᑖ᪆Ḅݯ஺#includevoidmain()(inta,b,c;printf("a=");scanf("%d"&a);printf(,,b=,*);scanf("%d"&b);printf(nc=");scanf(n%dn,&c);if(a

42%d%d

43",a,b,c);zelseprintf("

44%d%d

45"a,c,b);zz

46if(b

47%d%d%d

48n,b,a,c);zzelseprintf("

49%d%d,%d

50ub,c,a);zzif(c

51%d,%d,%d

52n,c,a,b);elseprintf(H

53%d%dc,b,a);zz}(ᑖ5ᵨ5,3,2+5,2,2Þß)a6ḄݯàᵨᡝᐭḄ3᦮ᦪâᑮᜧ.a=5b=2c=2□Pressanykeytocontinue.ÞßäCᨵBUG஺!᝞¥çᦋçᦋ£è<»¼éêᕖ§%4.20àᵨᡝᐭḄ5᦮ᦪᢥᓣ஺a:Itincludevoidruin()inta,b,cd,e,temp;yscanf('*%d%d%d%d%d*',&a,9&c,&e);/ᘂ<=>bḄ?.ABᑡa,bᨵWiF(a>b)cḄ?ABᑡa,b.cᨵ஻if(b>c)Hᡎᑡa,ᴈ”“EQ<=>eḄ?RBᑡa.b.c,d,eᨵ/iF(d>e)if(a>b)<if(c>d)“E<=>dḄ?,ABᑡa.b,c,dᨵ■/d)c-d;c)d-tenp;“KLMNᑡa,b,c᣸”c)b-c-b;c•c-b;if(a>b)b)a•b;>printf(U,b^%d,c-%d,d^%d,e-%d

54",a."PQ<=>eḄ?ABᑡa,b,c,d,eᨵ”

554.21ᑨîᵨᡝᐭḄ᦮ᦪ¯ᔲï2,3,5᦮◀᪷òéê[óô`c:1.¯õMï2,3,5᦮◀஺2.¯ïᐸC_!ö_%ᦪ᦮◀஺3.¯ïᐸCc!öc%ᦪ᦮◀஺4.¯ï2,3,5CḄ÷cᦪ᦮◀஺a6ttincludeuoidmain()3

56ஹn);10else±F(nú2==O&&n5==0)11û1⌭ý”,þ஺ø¶ï2+i5᦮◀\n);12elseiF(n%3==O&&n5==O)13p,intzFU*஺35᦮◀n,n);14elseiF(n2==0)15printzFC%஺⁐2᦮◀nn);16elseiF(n%3==0)17printFC%஺3᦮◀

57n);18elseiF(n5==0>19prinXC%஺5᦮◀n”n);20else21printer%஺2.3ᡈ5᦮◀

58n);22ᡈὅ

591^include2uoidmain()3{4intn,i=1;5scanFC^d",&n);6if(n%2==8)7i*=2;8iF(n%3==0)9i*=3;10iF(n%5==0)11i*=5;12switch(i)13<14case1:15printf("(d)8VW2,3,5᦮◀3-n);16break;17case2:18printf("(d)VW2᦮◀N

60”n);19break;20case3:21printf(,,(2d)VW3᦮◀N

61”,n);22break;23case5:24printf("(*d)VW5᦮◀N

62”,n);25break;26case6:27printf("ad)VW2,3᦮◀N

63”,n);28break;29case10:30printf(,,(Z)VW2,5᦮◀n“•n);31break;32case15:33(\*]”]ᦪ1VW3,5᦮◀\11“,n;34break;35case30:36printf("(d)VW2,3,5᦮◀

64”n);37break;38>39>4.224-19Ḅif-else᪀ᵫ4-14⊤ᑏ!"#$%Ḅ&'(ᑖ᪆+AஹBஹCஹDஹE-ᔜ/01234஺rade>=80grade>=90+A+B+C+D+E

654-144-19Ḅif-else᪀5:^include2uoidmain()3<4floatgrade;5scanFC%F",ftgrade);6iF(grade>100||grade<0)7{8printf("ᐭ┯^

66");9return;10>11if(grade>=80)12<13if(grade>=90)14putchar(iA');15else16putchar(*B*);17>18else“(grade>=70)19putchar('C');20else“(grade>=60)21putchar('D*);22else23putchar(aEa);24putchar('

67');25+AஹBஹCஹDஹE-ᔜ/012ஹ2ஹ2ஹ3ஹ34஺4.2378ᓬ:├<=>?@AḄ3B30ᝅDᝅ120ᐗFG30ᝅḄDᝅ150ᐗFHAI⊟DK90ᐗFHALMDᩩ80ᐗ஺O&PQR+ᐭᡠAI⊟LMḄKᦪ-+%VW஺XYZR+ᐭ2332-%ᢥ23ᝅ=>?9ᩩLM\]%VW஺5Z

681ttinclude2uoidmain()3<4intm9n9x,sum=0;5printf]“ᐭ_⊟abBḄcᦪ

69";6scanf("zd%d“&m,&n);7if(n<0||n<0)8<9Printf]”ᐭ┯⌨?

70“10return;11}12x=n>n?n:m;13if(x>=30)14sum=x*120;15else16sum=x*150;17if(n>n)18sum+=(n-x)*90;19else20sum♦=(n-x)*80;21printf("efg:3d

71”,sum);22>4.24O&PQ+ᐭ`&axbx+c=OḄpᦪ-+`&Ḅ᪷஺XYqᑖrst1.`&ᨵbᦪc᪷ea=b=c=Ok2.`&b᪷ea=b=O,cWOk3.`&HᨵcP᪷ea=O,b#Ok4.`&ᨵxcP᪷eᑨzx᪷{ᔲ#}k஺5.`&ᨵxc᪷e+3+2iḄ᪷k஺5:

72^include2ttinclude3uoidmain()4<5doublea,b,c,delt,m,n;6print*”ᐭhḄiᦪ

73”);7scanFCUfUFUf",&a,&b,&c);8iF(a==0)9<10iF(b==0)11if(c==0)12printf\jhᨵkᦪ᪷?

74");13else14printf(“jhk᪷n”)15else16printerjhmᨵn᪷o.2F?

75“-c/b);17>18else19<20delt=b*b-4*a*c;21n=-b/(2*a);22*(delt>0)23<24n=sqrt(delt)/(2*a);25printf(“jhᨵ$8pqḄn᪷:x1=%.2F,x2=Z.2f

76“m*n,26>27elseiF(delt==0)28printf(“jhᨵ$pqḄn᪷:x1=%.2f,x2=%.2F

77",m,n>);29else3031n=sqrt(-delt)/(2*a);32printf(1ᘧhᨵ$s᪷஺.2f+Z.2fi,%.2F-%.2fi

78",n,n,n,3334354.25+ᐭḄᩩ᪷st+rḄ஺I.ᡂ}2.ᡂ}Ὺ3.ᡂ}Ὺeᦪ2.3,3.252691,2.3k4.ᡂ5.ᡂ6.ᡂ஺5:

791ttinclude2•include3uoidmain()<5doublea,b,c,flag=0;6printfᐭᩩvw

80");7&a,&b,&c);8if(a+b<=c||a+c<=b||b+c<=a)9printf("v8V᪀ᡂz{

81”)10elseiF(a==b&&a==c&&b==c)prints”v|}~ᡂqvz{

82“);12else13(14if(Fabs(a*a+b*b-c»c)<1e-5||Fabs(a*a+c*c-b*b)<1e-5||fabs(c*c+b*b-a*a)<1e-5)15Flag=1;16else17Flag=0;18"(a==b11a==c11b-=c)19<20“(flag==1)21printf(“v|}~ᡂqῪzz{

83“);22else23printf\v|}~ᡂqῪz{

84“);2h}25else“(flag==1)26printf\v|}~ᡂzz{;27else28printf("v|}~ᡂz{?

85");29>30>4.26(1kᵨif⌱᪀PQ1'^include2uoidmain()3<4charca;5ca=getchar();6iF(ca=='c")7putchar(ca);8if(ca=='b')9putchar(ca);10iF(ca=='a")11putchar(ca);12if(ca?='c'&&ca?="b"&&ca?='a')13printf,ᐭḄ86a,bᡈc?

86");14>(2)ᵨif-else⌱᪀PQ1~^include2uoidmain()3<4charca;5ca=getchar();6if(ca=='c')7putchar(ca);8elseif(ca=='b')9putchar(ca);10elseif(ca=="a*)11putchar(ca);12else13printf,•ᐭḄ86a,bᡈc

87";14

88(3)ᵨswitch⌱᪀PQ1^include2uoidmain()3<4charca;5ca=getchar();6suitch(ca)7<8case'c":9putchar(ca);10break;11case'b":12putchar(ca);13break;14case'a':15putchar(ca);16break;17default:18printf(“ᐭḄ86a,bᡈ1920(4)/0ᩭ,ᵨif⌱᪀ᦔ᳛஺ᵨif-else⌱᪀switch⌱᪀Ḅᦔ᳛0¡xὅ/0Ḅ¢switch⌱᪀ᙠ"ᩩKr¤¥ᵨ஺

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
最近更新
更多
大家都在看
近期热门
关闭