|
发表于 2021-10-21 12:35:38
|
显示全部楼层
0.
10个
1.
0个
2.
a, b, c
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.
while (1)
{
scanf("%d", &score);
if (score < 0)
{
break;
}
count++;
}
printf("count = %d\n", count);
动动手
0.
- #include <stdio.h>
- #define PRINCIPAL 10000
- int main()
- {
- float principal1 = PRINCIPAL, principal2 = PRINCIPAL;
- int year;
-
- for (year = 0; principal1 >= principal2; year++)
- {
- principal1 += PRINCIPAL * 0.1;
- principal2 *= 1 + 0.05;
- }
-
- printf("%d年后 , 黑夜的投资额超过小甲鱼!\n小甲鱼的投资额是 : %.2f\n黑夜的投资额是 : %.2f\n", year, principal1, principal2);
-
- return 0;
- }
复制代码
1.
- #include <stdio.h>
- int main ()
- {
- int year;
- float money = 400;
-
- for (year = 0; money > 0; year++)
- {
- money -= 50;
- money *= 1.08;
- }
-
- printf("%d年之后 , 小甲鱼败光了所有的家产 , 再次回到一贫如洗......\n", year);
-
- return 0;
- }
复制代码
2.
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- double sum = 0, num = 1.0;
-
- do
- {
- sum += num;
- }while (fabs(num = -1.0/(num < 0 ? 1.0/num - 2 : 1.0/num + 2)) >= pow(10, -8));
- printf("%.7f", 4 * sum);
-
- return 0;
- }
复制代码
3.
- #include <stdio.h>
- int main()
- {
- int a = 1, b = 1, temp;
-
- for (int i = 2; i < 24; i++)
- {
- temp = b;
- b = a + b;
- a = temp;
- }
-
- printf("两年后可以繁殖%d次\n", b);
-
- return 0;
- }
复制代码 |
|