编译器:Dev-C++
/*第一题*/
#include <stdio.h>
#include <math.h>
int main(void)
{
double p,r=0.09,n=10.0;
p = pow ((1 + r), n);
printf ("倍数为%f\n", p);
return 0;
//我也不知道倍数为什么会这么高..
}
/*第二题*/
#include <stdio.h>
#include <math.h>
int main(void)
{
double p1, p2, p3, p4, p5;
p1 = 1000.0 * (1 + 5 * 0.0585);
p2 = (1000.0 * (1 + 2 * 0.0468)) * (1 + 3 * 0.054);
p3 = (1000.0 * (1 + 3 * 0.054)) * (1 + 2 * 0.0468);
p4 = 1000.0 * (pow((1 + 0.0414), 5));
p5 = 1000.0 * (pow((1 + 0.0072/4), 20));
printf("p1 = %.2f\n", p1); //p1为1292.50
printf("p2 = %.2f\n", p2); //p2为1270.76
printf("p3 = %.2f\n", p3); //o3为1270.76
printf("p4 = %.2f\n", p4); //p4为1224.86
printf("p5 = %.2f\n", p5); //p5为1036.62
return 0;
}
/*第三题*/
#include <stdio.h>
#include <math.h>
int main(void)
{
double d = 300000.0, p = 6000.0, r = 0.01;
double m = (log10(p / (p- d*r))) / (log10(1 + r));
printf("%.1f", m); //m为69.7
return 0;
}
/*第四题*/
#include <stdio.h>
int main(void)
{
char c1, c2;
c1 = 97;
c2 = 98;
printf("c1=%c,c2=%c\n", c1, c2);
printf("c1=%d,c2=%d\n", c1, c2);
return 0;
}
//(1) c1=a,c2=b
// c1=97,c2=98
//(2) c1=?,c2=?
// c1=-59,c2=-58
//(3) c1=?,c2=?
// c1=197,c2=198
//这里之所以字符为'?'是因为编译器不支持扩展ascii码
/*第五题*/
#include <stdio.h>
int main(void)
{
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);
return 0;
}// 按以下方式输入
// a=3b=7 8.5 71.82 Aa
/*第六题*/
#include <stdio.h>
int main(void)
{
char c1 = 'C', c2 = 'h', c3 = 'i', c4 = 'n', c5 = 'a';
putchar(c1+4);
putchar(c2+4);
putchar(c3+4);
putchar(c4+4);
putchar(c5+4);
putchar('\n');
printf("%c%c%c%c%c\n", c1+4, c2+4, c3+4, c4+4, c5+4);
return 0;
}
/*第七题*/
#include <stdio.h>
int main(void)
{
double r, h, pi = 3.1416;
printf("请输入圆的半径和圆柱的高:\n");
scanf("%lf %lf", &r, &h);
printf("圆的周长为%.2f\n", 2*r*pi);
printf("圆的面积为%.2f\n", pi*r*r);
printf("圆球的表面积为%.2f\n", 4.0*pi*r*r);
printf("圆球的体积为%.2f\n", 4.0*pi*r*r*r/3.0);
printf("圆柱的体积为%.2f\n", pi*r*r*h);
return 0;
}
//圆的周长为9.42
//圆的面积为7.07
//圆球的表面积为28.27
//圆球的体积为14.14
//圆柱的体积为21.21
第八题自己看看char跟int型的区别就明白了