chapter3习题

时间:2023-03-10 05:29:26
chapter3习题
// 2013年11月4日21:47:21
# include <stdio.h>
# include <math.h>
int main()
{
int n;
double p, r;
scanf("%d%lf", &n, &r); p = pow((1+r), n); printf("%lf\n", p);
return 0;
}
/*
--------------------------------------
在VC++6.0中的输出结果是:
10 0.09
2.367364
Press any key to continue
--------------------------------------
*/
//	2013年11月5日13:18:59

# include <stdio.h>
int main()
{
// char c1, c2;
/*
c1 = 97; 当输入这些值得时候,输出结果为,a,b; 97,98 出现这个结果的原因是,%c是以字符的形式输出,而%d则是以一个十进制整数输出
c2 = 98;
*/ /*
c1 = 197; 在这里输入的结果为,?,?; -59,-58
c2 = 198; 出现这个结果的原因是因为,ASCII一般只用7位,也就是128个字符,超过的话,则无法显示,而用十进制显示的时候,则直接字符运算
*/ /*
int c1, c2; 当用int来取代char的时候,用%c依然是没有符号对应,而用十进制输出的时候,可以输出,十进制的值
c1 = 197;
c2 = 198;
*/
printf("c1 = %c, c2 = %c\n", c1, c2);
printf("c1 = %d, c2 = %d\n", c1, c2); return 0;
}
// 2013年11月5日13:40:47
# include <stdio.h>
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 = %e, c1 = %c, c2 = %c\n", a, b, x, y, c1, c2); return 0;
}
/*
-----------------------------------------
在VC++6.0中的输出结果是:
a=3b=7
8.5 71.82Aa
a = 3, b= 7, x = 8.500000, y = 7.182000e+001, c1 = A, c2 = a
Press any key to continue 这个里面必须要记住,Aa必须要紧跟着71.82输入
----------------------------------------
*/
// 2013年11月5日21:37:36
// 编码
# include <stdio.h>
int main()
{
char c1, c2, c3, c4, c5;
scanf("%c%c%c%c%c", &c1, &c2, &c3, &c4, &c5);
c1 = c1 + 5;
c2 = c2 + 5;
c3 = c3 + 5;
c4 = c4 + 5;
c5 = c5 + 5; printf("%c%c%c%c%c\n", c1, c2, c3, c4, c5); return 0;
}