C程序设计(第三版)谭浩强 清华大学出版社 课后习题答案
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
5∙6
ma()
(imSCOreJemPJOgi
Chargrad
logic"
while(logic)
{scanf("%d",&score);
if(score>=0&&score<=100)logic=0;
}
if(score==100)
temp=9;
else
temp=(score-score%10)/10;
Se
Printf(=maxH%d∖n.vx
ma5()
(imPbQiernPrnaX-
Scan%α%α%4a4b4
mpHvb)*?
maxH&vmpCJemp-
Prtf(=max"%dJmaxx
5∙5
ma()
(imXy
scan%"©
if(XAl)y"x-
Seif(XA10)y"2*xl
Sey"3*x
Prtf(=y"%dm
{
int max(int x,int y,int z);
int a,b,c,d; scanf("%d,%d,%d",&a,&b,&c); d=max(a,b,c);
printf("max=%d\n",d);
}
int max(int x,int y,int z)
{
int A,B;
if(x>y) A=x;
3.8
main()
{int c1,c2; c1=97;c2=98;
printf("%c %c",c1,c2);
}
SOO畐Hndwoω
I,⅛KZEUR鞭9
Z89pzozy孚Z9孚EZI
EIogv
ZOO+068Z,二。。+。Oi79SZ.9
Z96gzl.68ro'oi79sz9γ96gzl.68τo'oi79sz971.68r98Z9
4.7
10 20Aa1.5-3.75 +1.4,67.8/
(空3)10(空3)20Aa1.5(空1)-3.75(空1)(随意输入一个数),67.8回车
4.8
main()
{float pi,h,r,l,s,sq,sv,sz;
pi=3.1415926;
printf("input r,h\n");
scanf("%f,%f",&r,&h);
-(M-⅛u⅛
÷>9Z8ZIUU⅛ZZpnETZFEZIUX^HO^X∞⅛
IBq"ZyxOJJWnMUOIqIU二()uUI
寸寸
≡≡≡0(9)O(OO(17)09(O≡(z)17Z(I)
Zls
Or6d"6
OIS
SSAZ)『ZAD
6S
4.6
a=3 b=7/
x=8.5 y=71.82/
c1=A c2=a/
(6)(2483)10=(4663)8=(963)16
(7)(-28654)10=(110022)8=(9012)16
(8)(21003)10=(51013)8=(520b)16
3.6
aabb (8)cc (8)abc
(7)AN
3.7
main()
{char c1='C',c2='h',c3='i',c4='n',c5='a'; c1+=4, c2+=4, c3+=4, c4+=4, c5+=4; printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5);}
}
(法二)
main()
{
int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c); if(a>b&&a>c)
max=a;
else if (b>c)
max=b;
else
max=c;
printf("max=%d\n",max);
}
(法三)
#include <stdio.h>
void main()
switch(temp)
{case 9:grade='A';break;
case 8:grade='B';break;
case 7:grade='C';break;
case 6:grade='D';break;
case 5:
case 4:
Z96gzl.68ro'oi79sz9
Z96gzl.68ro'oi79sz9
⅛c∙3M(5sv)p%-loQ%-uzθ⅛u⅛"(ooM(5SV)P%」0Q%-uQ-⅛u⅛
⅛5-u∖pi6%uuPI9%un-⅛u⅛⅛+zN+AFX“=眉常X+ZJZ.常Z+AJZS<⅛*X-⅛U⅛
⅛kx"=uv9.6%UZ“J9.8%占9.8%UX-⅛u⅛⅛q5-u∖pz%bpz%uqpz%ue-⅛u⅛
putchar(c1);
putchar(c2);
printf("\n");
printf("%c%c\n",c1,c2);
MWW
5∙3
(wenku.baidu.com)O(2)1(3)1(4)0(5)1
5∙4
ma()
(imPbg
Scan%α%α%4a4b4
if(aAb)
if(bAC)
Se
Printf(=maxH%d∖nJbr
Seif(aAC)
printf("vz=%6.2f\n",sz);
}
4.9
main()
{float c,f;
scanf("%f",&f);
c=(5.0/9.0)*(f-32);
printf("c=%5.2f\n",c);
}
4.10
#include"stdio.h"
main()
{char c1,c2;
scanf("%c,%c",&c1,&c2);
l=2*pi*r;
s=r*r*pi;
sq=4*pi*r*r;
sv=4.0/3.0*pi*r*r*r;
sz=pi*r*r*h;
printf("l=%6.2f\n",l);
printf("s=%6.2f\n",s);
printf("sq=%6.2f\n",sq);
printf("vq=%6.2f\n",sv);
else A=y;
if(z>A) B=z;
else B=A; return(B);
}
第三章
3.3
(1)(10)10=(12)8=(a)16
(2)(32)10=(40)8=(20)16
(3)(75)10=(113)8=(4b)16
(4)(-617)10=(176627)8=(fd97)16
(5)(-111)10=(177621)8=(ff91)16
第一章
1.5 #include <stdio.h> void main()
{
printf("* * * * * * * * *\n
1.6
(法一)
#include <stdio.h>
main()
{
int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c); max=(a>b)?a:b; max=(max>c)?max:c; printf("max=%d\n",max);
ma()
(imSCOreJemPJOgi
Chargrad
logic"
while(logic)
{scanf("%d",&score);
if(score>=0&&score<=100)logic=0;
}
if(score==100)
temp=9;
else
temp=(score-score%10)/10;
Se
Printf(=maxH%d∖n.vx
ma5()
(imPbQiernPrnaX-
Scan%α%α%4a4b4
mpHvb)*?
maxH&vmpCJemp-
Prtf(=max"%dJmaxx
5∙5
ma()
(imXy
scan%"©
if(XAl)y"x-
Seif(XA10)y"2*xl
Sey"3*x
Prtf(=y"%dm
{
int max(int x,int y,int z);
int a,b,c,d; scanf("%d,%d,%d",&a,&b,&c); d=max(a,b,c);
printf("max=%d\n",d);
}
int max(int x,int y,int z)
{
int A,B;
if(x>y) A=x;
3.8
main()
{int c1,c2; c1=97;c2=98;
printf("%c %c",c1,c2);
}
SOO畐Hndwoω
I,⅛KZEUR鞭9
Z89pzozy孚Z9孚EZI
EIogv
ZOO+068Z,二。。+。Oi79SZ.9
Z96gzl.68ro'oi79sz9γ96gzl.68τo'oi79sz971.68r98Z9
4.7
10 20Aa1.5-3.75 +1.4,67.8/
(空3)10(空3)20Aa1.5(空1)-3.75(空1)(随意输入一个数),67.8回车
4.8
main()
{float pi,h,r,l,s,sq,sv,sz;
pi=3.1415926;
printf("input r,h\n");
scanf("%f,%f",&r,&h);
-(M-⅛u⅛
÷>9Z8ZIUU⅛ZZpnETZFEZIUX^HO^X∞⅛
IBq"ZyxOJJWnMUOIqIU二()uUI
寸寸
≡≡≡0(9)O(OO(17)09(O≡(z)17Z(I)
Zls
Or6d"6
OIS
SSAZ)『ZAD
6S
4.6
a=3 b=7/
x=8.5 y=71.82/
c1=A c2=a/
(6)(2483)10=(4663)8=(963)16
(7)(-28654)10=(110022)8=(9012)16
(8)(21003)10=(51013)8=(520b)16
3.6
aabb (8)cc (8)abc
(7)AN
3.7
main()
{char c1='C',c2='h',c3='i',c4='n',c5='a'; c1+=4, c2+=4, c3+=4, c4+=4, c5+=4; printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5);}
}
(法二)
main()
{
int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c); if(a>b&&a>c)
max=a;
else if (b>c)
max=b;
else
max=c;
printf("max=%d\n",max);
}
(法三)
#include <stdio.h>
void main()
switch(temp)
{case 9:grade='A';break;
case 8:grade='B';break;
case 7:grade='C';break;
case 6:grade='D';break;
case 5:
case 4:
Z96gzl.68ro'oi79sz9
Z96gzl.68ro'oi79sz9
⅛c∙3M(5sv)p%-loQ%-uzθ⅛u⅛"(ooM(5SV)P%」0Q%-uQ-⅛u⅛
⅛5-u∖pi6%uuPI9%un-⅛u⅛⅛+zN+AFX“=眉常X+ZJZ.常Z+AJZS<⅛*X-⅛U⅛
⅛kx"=uv9.6%UZ“J9.8%占9.8%UX-⅛u⅛⅛q5-u∖pz%bpz%uqpz%ue-⅛u⅛
putchar(c1);
putchar(c2);
printf("\n");
printf("%c%c\n",c1,c2);
MWW
5∙3
(wenku.baidu.com)O(2)1(3)1(4)0(5)1
5∙4
ma()
(imPbg
Scan%α%α%4a4b4
if(aAb)
if(bAC)
Se
Printf(=maxH%d∖nJbr
Seif(aAC)
printf("vz=%6.2f\n",sz);
}
4.9
main()
{float c,f;
scanf("%f",&f);
c=(5.0/9.0)*(f-32);
printf("c=%5.2f\n",c);
}
4.10
#include"stdio.h"
main()
{char c1,c2;
scanf("%c,%c",&c1,&c2);
l=2*pi*r;
s=r*r*pi;
sq=4*pi*r*r;
sv=4.0/3.0*pi*r*r*r;
sz=pi*r*r*h;
printf("l=%6.2f\n",l);
printf("s=%6.2f\n",s);
printf("sq=%6.2f\n",sq);
printf("vq=%6.2f\n",sv);
else A=y;
if(z>A) B=z;
else B=A; return(B);
}
第三章
3.3
(1)(10)10=(12)8=(a)16
(2)(32)10=(40)8=(20)16
(3)(75)10=(113)8=(4b)16
(4)(-617)10=(176627)8=(fd97)16
(5)(-111)10=(177621)8=(ff91)16
第一章
1.5 #include <stdio.h> void main()
{
printf("* * * * * * * * *\n
1.6
(法一)
#include <stdio.h>
main()
{
int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c); max=(a>b)?a:b; max=(max>c)?max:c; printf("max=%d\n",max);