Cプログラム設計(第五版)譚浩強第三章練習問題のすべての答え
3260 ワード
#include
#include
int main(){
int i=10;
double r=0.07,p;
p=pow((1+r),i);
printf(" :%lf
",p);
return 0;
}
2
.#include
#include
/** :r ,n ,
1 :P=1000*(1+r);
n :P=1000*(1+n*r)
n 1 :P=1000*(1+r)N
:P=1000*(1+r/4)4n */
int main(){
int m; //
double p1,p2,p3,ph,p5;//p1 ,p2 2+3,p3 3+2,ph,p5
double r1=0.015,r2=0.021,r3=0.0275,r5=0.03,rh=0.0035; //
m=1000;
p1=m*(1+5*r5);// 5
p2=m*(1+2*r2)*(1+3*r3);// 2 , 3
p3=m*(1+3*r3)*(1+2*r2); // 3 , 2
ph=m*pow((1+r1),5); // 1 ,
p5=m*pow((1+r5/4),4*5); //
printf(" =%lf
",p1);
printf(" =%lf
",p2);
printf(" 3 =%lf
",p3);
printf(" =%lf
",ph);
printf(" =%lf
",p5);
return 0;
}
3
.#include
#include
main()
{
int d=300000,p=6000;
double r=0.01,m,h,l;
h=p/(p-d*r);
l=1+r;
m=log10(h)/log10(l);
printf(" = %6.1f
",m);
return 0;
}
#include
int main(){
char c1,c2;
c1=97;
c2=98;
printf("c1=%c,c2=%c
",c1,c2);
printf("c1=%d,c2=%d
",c1,c2);
return 0;
}
1)a,b,97,97
%c
%d
2)?,?,197,198
3)a,b,97,98
#include
int main()
{
int a, b;
float x, y;
char c1, c2;
scanf("a=%db=%d",&a,&b);
scanf("%f %e",&x,&y);
scanf("%c%c", &c1, &c2);
printf("a=%d,b=%d,x=%f,y=%f,c1=%c,c2=%c",a,b,x,y,c1,c2);
return 0;
}
a=3b=7 8.5 71.82Aa
6).
#include
#include //#include"string.h" , C 。 ,
main()
{
char c1='C',c2='h', c3='i', c4='n', c5='a';
c1+=4;
c2+=4;
c3+=4;
c4+=4;
c5+=4;
printf(" :");
putchar(c1);
putchar(c2);
putchar(c3);
putchar(c4);
putchar(c5);
printf("
:%c%c%c%c%c
",c1,c2,c3,c4,c5);
return 0;
}
#include
#include
int main()
{
double PI=acos(-1.0); // -1 , 3.141593
double r,h,c,s,bs,bv,v;
printf(" r, H,
");
scanf("%lf %lf",&r,&h);
c=2*PI*r;
s=PI*r*r;
bs=4*PI*r*r;
bv=4*PI*r*r/3;
v=s*h;
printf(" = %.2lf
",c);
printf(" = %.2lf
",s);
printf(" = %.2lf
",bs);
printf(" = %.2lf
",bv);
printf(" = %.2lf
",v);
return 0;
}