[VIP专享]c语言程序设计课后习题答案 第四章
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
while(grade>=0) {
sum=sum+grade; if(grade<60)
bujige=bujige+1; n=n+1; scanf("%lf",&grade); } ave=sum/n; printf("ave=%lf\n",ave); printf("bujige=%d\n",bujige); }
/*练习 4-4*/ #include<stdio.h> main() { int n=-1,bujige=-1;
double chengji=0,sum=0,ave; printf("enter n ge zheng zheng shu \n"); while(chengji>=0) {
sum=sum+chengji; n++; if(chengji>=0&&chengji<=60)
/*习题 4 4*/ #include<stdio.h> main() {
int x1,x2,i,n,x; double item,sum; printf("enter n:\n"); scanf("%d",&n); x1=2;x2=1; sum=0; for(i=1;i<=n;i++) {
item=1.0*x1/x2; sum=sum+item; x=x1+x2; x2=x1; x1=x; } printf("sum=%.2lf\n",sum);
1) B2Ak+22+1=2+15+c51mc+=m5=21c11+m++12+2+1++=212=2+1+2+1+2+2+22+32k+1+2
/*练习 4-3*/ #include<stdio.h> main() { int n=-1,bujige=-1;
double grade=0,sum=0,ave; printf("enter grade:\n");
bujige=bujige+1; scanf("%lf",&chengji); } ave=sum/n; printf("ave=%lf\n",ave); printf("bujige=%d\n",bujige);
88.8918÷1.2990÷.1=4214÷3922=.0034=1÷15251371=8535.78.208÷023.2173c00÷1*m=29030.3922c=.1÷20m3=2÷120252.=3535=42314c)*523m240341*31.252=31*.1.535.*031342.*9205221.04.455=+213*05*2022.02.854850.3150.*+58c12*5m1*202+.050+0.014*85.20*051000+0+03/8T.+0÷+=55+1*011+010+91÷01454050*0010200+5+0+080+400*+4**1*1510.3910%*C%-*6+÷M(=*M=5÷50)*30*31(÷3110*5+**÷4*1m243.%71e=78%n0)8=8s.5=77.93c.6c0mmc.4*m1*31,0w199o.k2.m4c-cem.5mn2csp26m659*.0.34-50.60c5*pm.3c85m9,c05g.m.05i0rp-l.s.85p6/c50bcm0.om7py.c.6spm5c+mc;0m..7.cmk ; 1+1k+12+1+k2234=1c+m1++4+4+2
if(m==1) printf(Байду номын сангаас1 bu shi su shu \n");
else { for(j=2;j<=m/2;j++)
if(m%j==0) break;
1) B2Ak+22+1=2+15+c51mc+=m5=21c11+m++12+2+1++=212=2+1+2+1+2+2+22+32k+1+2
}
/*练习 4-7*/ #include<stdio.h> main() { int n,i,j,m;
printf("enter zheng zheng shu n:\n"); scanf("%d",&n); printf("enter n ge zheng zheng shu:\n"); for(i=1;i<=n;i++) {scanf("%d",&m);
}
/*练习 4-3*/ #include<stdio.h> #include<math.h> main() { int a=-1,t=-2; double eps,s=0,item=1; printf("enter eps:\n"); scanf("%lf",&eps); while(fabs(item)>=eps) {
t=t+3; a=-a; item=a*1.0/t;
s=s+item; } printf("s=%lf\n",s); }
88.8918÷1.2990÷.1=4214÷3922=.0034=1÷15251371=8535.78.208÷023.2173c00÷1*m=29030.3922c=.1÷20m3=2÷120252.=3535=42314c)*523m240341*31.252=31*.1.535.*031342.*9205221.04.455=+213*05*2022.02.854850.3150.*+58c12*5m1*202+.050+0.014*85.20*051000+0+03/8T.+0÷+=55+1*011+010+91÷01454050*0010200+5+0+080+400*+4**1*1510.3910%*C%-*6+÷M(=*M=5÷50)*30*31(÷3110*5+**÷4*1m243.%71e=78%n0)8=8s.5=77.93c.6c0mmc.4*m1*31,0w199o.k2.m4c-cem.5mn2csp26m659*.0.34-50.60c5*pm.3c85m9,c05g.m.05i0rp-l.s.85p6/c50bcm0.om7py.c.6spm5c+mc;0m..7.cmk ; 1+1k+12+1+k2234=1c+m1++4+4+2
sum=sum+grade; if(grade<60)
bujige=bujige+1; n=n+1; scanf("%lf",&grade); } ave=sum/n; printf("ave=%lf\n",ave); printf("bujige=%d\n",bujige); }
/*练习 4-4*/ #include<stdio.h> main() { int n=-1,bujige=-1;
double chengji=0,sum=0,ave; printf("enter n ge zheng zheng shu \n"); while(chengji>=0) {
sum=sum+chengji; n++; if(chengji>=0&&chengji<=60)
/*习题 4 4*/ #include<stdio.h> main() {
int x1,x2,i,n,x; double item,sum; printf("enter n:\n"); scanf("%d",&n); x1=2;x2=1; sum=0; for(i=1;i<=n;i++) {
item=1.0*x1/x2; sum=sum+item; x=x1+x2; x2=x1; x1=x; } printf("sum=%.2lf\n",sum);
1) B2Ak+22+1=2+15+c51mc+=m5=21c11+m++12+2+1++=212=2+1+2+1+2+2+22+32k+1+2
/*练习 4-3*/ #include<stdio.h> main() { int n=-1,bujige=-1;
double grade=0,sum=0,ave; printf("enter grade:\n");
bujige=bujige+1; scanf("%lf",&chengji); } ave=sum/n; printf("ave=%lf\n",ave); printf("bujige=%d\n",bujige);
88.8918÷1.2990÷.1=4214÷3922=.0034=1÷15251371=8535.78.208÷023.2173c00÷1*m=29030.3922c=.1÷20m3=2÷120252.=3535=42314c)*523m240341*31.252=31*.1.535.*031342.*9205221.04.455=+213*05*2022.02.854850.3150.*+58c12*5m1*202+.050+0.014*85.20*051000+0+03/8T.+0÷+=55+1*011+010+91÷01454050*0010200+5+0+080+400*+4**1*1510.3910%*C%-*6+÷M(=*M=5÷50)*30*31(÷3110*5+**÷4*1m243.%71e=78%n0)8=8s.5=77.93c.6c0mmc.4*m1*31,0w199o.k2.m4c-cem.5mn2csp26m659*.0.34-50.60c5*pm.3c85m9,c05g.m.05i0rp-l.s.85p6/c50bcm0.om7py.c.6spm5c+mc;0m..7.cmk ; 1+1k+12+1+k2234=1c+m1++4+4+2
if(m==1) printf(Байду номын сангаас1 bu shi su shu \n");
else { for(j=2;j<=m/2;j++)
if(m%j==0) break;
1) B2Ak+22+1=2+15+c51mc+=m5=21c11+m++12+2+1++=212=2+1+2+1+2+2+22+32k+1+2
}
/*练习 4-7*/ #include<stdio.h> main() { int n,i,j,m;
printf("enter zheng zheng shu n:\n"); scanf("%d",&n); printf("enter n ge zheng zheng shu:\n"); for(i=1;i<=n;i++) {scanf("%d",&m);
}
/*练习 4-3*/ #include<stdio.h> #include<math.h> main() { int a=-1,t=-2; double eps,s=0,item=1; printf("enter eps:\n"); scanf("%lf",&eps); while(fabs(item)>=eps) {
t=t+3; a=-a; item=a*1.0/t;
s=s+item; } printf("s=%lf\n",s); }
88.8918÷1.2990÷.1=4214÷3922=.0034=1÷15251371=8535.78.208÷023.2173c00÷1*m=29030.3922c=.1÷20m3=2÷120252.=3535=42314c)*523m240341*31.252=31*.1.535.*031342.*9205221.04.455=+213*05*2022.02.854850.3150.*+58c12*5m1*202+.050+0.014*85.20*051000+0+03/8T.+0÷+=55+1*011+010+91÷01454050*0010200+5+0+080+400*+4**1*1510.3910%*C%-*6+÷M(=*M=5÷50)*30*31(÷3110*5+**÷4*1m243.%71e=78%n0)8=8s.5=77.93c.6c0mmc.4*m1*31,0w199o.k2.m4c-cem.5mn2csp26m659*.0.34-50.60c5*pm.3c85m9,c05g.m.05i0rp-l.s.85p6/c50bcm0.om7py.c.6spm5c+mc;0m..7.cmk ; 1+1k+12+1+k2234=1c+m1++4+4+2