|
发表于 2019-9-13 20:29:48
|
显示全部楼层
测试题:
0. 10 个
1. 0 个
2. a,b,c
3. a:14,b:5,c:9
4.
5.
A.- if (size > 12)
- {
- cost = cost * 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B.- if (ibex > 14)
- {
- sheds = 3;
- }
- sheds = 2;
- help = 2 * sheds;
复制代码
C.- scanf("%d", &score);
- while (score >= 0)
- {
- count++;
- scanf("%d", &score);
- }
- printf("count = %d\n", count);
复制代码
动动手:
0.- #include <stdio.h>
- #define INTEREST1 0.1
- #define INTEREST2 0.05
- int main()
- {
- double m1 = 10000;
- double m2 = 10000;
- int year = 0;
-
- while (m1 >= m2)
- {
- m1 += 10000 * INTEREST1;
- m2 *= (1 + INTEREST2);
-
- year++;
- }
-
- printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
- printf("小甲鱼的投资额是:%.2f\n", m1);
- printf("黑夜的投资额是:%.2f\n", m2);
-
- return 0;
- }
复制代码
1.- #include <stdio.h>
- int main()
- {
- float money = 4000000;
- int year = 0;
-
- while (money > 0)
- {
- year++;
- money -= 500000;
- money *= 1.08;
- }
-
- printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", year);
-
- return 0;
- }
复制代码
2.- #include <stdio.h>
- #include <math.h>
- int main()
- {
- double temp = 0;
- int denominator = 1; // 分母
- double each = 1 / denominator;
-
- while (fabs(each) >= pow(10, -8))
- {
- temp += each;
- denominator += 2;
- each = 1 / (float)denominator;
- if (denominator % 4 == 3)
- {
- each = -each;
- }
- }
-
- printf("精确到小数点后 7 位的圆周率为:%.7f\n", 4 * temp);
-
- return 0;
- }
复制代码
3.- #include <stdio.h>
- int main()
- {
- int time;
- int a = 1, b = 1, temp;
-
- for (time = 0; time < 24 - 1; time++)
- {
- temp = a;
- a = b;
- b = temp + b;
- }
-
- printf("两年之后可以繁殖%d对兔子\n", a);
-
- return 0;
- }
复制代码 |
|