第5章以后的答案
第五章答案
-1-
1. 【答案】: (1) m=1 n=2 (2) m=2 n=3 (3) a>0 并且a
2. 【答案】:
(2)for (i=0;i<10;i++) {……} 3. 【答案】:32 4. 【答案】: main() {
char x ;
int y;
printf("please input :");
scanf("%c",&x); if(x>=0 && x<=31)
printf("%c is controll char.",x); else if(x>=48 && x<=57) printf("%c is number.",x); else if(x>='a' && x<='z')
printf("%c is min letter.",x); else if(x>='A' && x<='Z')
printf("%c is max letter.",x); else if((x>=8 &&
x<=13)||(x=92)||(x=39)||(x=34))
printf("%c is transferred meaning char:"); else
printf("%c is other char.") ; }
5. 【答案】: main() {
float x;
printf("please input x:"); scanf("%f",&x); if(x>10) x=x*x+0.5;
else if(x>0 && x<=10) x=x*x*x-1;
-2-
else if(x<=0) x=x*x+4*x;
printf("%f",x); }
6. 【答案】:
#include main( ) {
double m,i=0.0;
int t;
printf("输入存入的本金:");
scanf("%lf",&m);
printf("\n 输入存钱的期限(整年数):"); scanf("%d",&t); switch(t) {
case 1:i=m*0.00225;break; case 2:i=m*0.00276;break; case 3:i=m*0.00316;break; case 4:i=m*0.00395;break; case 5:i=m*0.00470;break;
}
printf("到期时的利息为%lf,利息与本金的合计为%lf",i,m+i); }
7. 【答案】: main() { int x;
int z,z1,z2;
printf("please input a number x(0==100) {
z1=x/100; x=x-z1*100; z2=x/10; x=x-z2*10;
-3-
z=z1+z2+x; }
else if(x>=10) {
z1=x/10; x=x-z1*10; z=z1+x;