|
发表于 2025-2-17 13:38:17
|
显示全部楼层
0. 10个
1. 0个
2. a
3. a=14,b = 5,c = 9
4. z = x>=0 ? x : -x
5.
A
- if (size > 12)
- {
- cost = cost * 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B:
- if (ibex > 14)
- {
- sheds = 3;
- }
- else
- {
- sheds = 2;
- }
- help = 2 * sheds;
-
复制代码
C,
- do {
- scanf("%d", &score);
- count++;
- } while (score > 0);
- printf("count = %d\n", count);
复制代码
0.
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- double money = 10000;
- double xjy, hy;
- int time = 0;
- xjy = 10000, hy = 10000;
- while (1)
- {
- if (xjy < hy)
- {
- break;
- }
- xjy = 10000, hy = 10000;
- xjy = xjy + money * 0.10 * time;
- hy = hy * pow(1 + 0.05, time);
- time++;
- }
- printf("%d年后,黑夜的投资额超过小甲鱼 !\n", time);
- printf("小甲鱼的投资额是:%.2lf\n", xjy);
- printf("黑夜的投资额是:%.2lf\n", hy);
- return 0;
- }
复制代码
1.
- #include <stdio.h>
- int main()
- {
- double money = 4000000;
- int time = 0;
- while (money > 0)
- {
- money -= 500000;
- money += money * 0.08;
- time++;
- }
- printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......", time);
- return 0;
- }
复制代码
2.
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int i, sign = 1;
- double pi = 0, s = 1;
- for (i = 1; fabs(s) > 1 / 1e8; i += 2)
- {
- s = sign * (1.0 / i);
- sign *= -1;
- pi += s;
- }
- pi = 4 * pi;
- printf("pi = %.7lf", pi);
- return 0;
- }
复制代码
3.
- #include <stdio.h>
- int main()
- {
- int a = 0, b = 1;
- int i;
- for (i = 0; i < 24; i++)
- {
- int t = b;
- b = a + b;
- a = t;
- }
- printf("两年后有%d对兔子", b);
- return 0;
- }
复制代码 |
|