|
发表于 2021-2-27 19:24:10
|
显示全部楼层
测试题
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;
}
else
{
bill = cost * flag;
}
B.
if (ibex > 14)
{
sheds = 3;
}
sheds = 2;
help = 2 * sheds;
C.
if (score < 0)
{
printf("count = %d", count);
}
count++;
scanf("%d", &score);
动动手
0.
#include <stdio.h>
int main()
{
int i = 1;
float xjy = 10000, hy = 10000;
while (i++)
{
xjy = xjy + 10000 * 0.1;
hy = hy * (0.05 + 1);
if (hy > xjy)
{
printf("%d年后,黑夜的投资额超过小甲鱼!\n", i);
printf("小甲鱼的投资额是:%.2f\n", xjy);
printf("黑夜的投资额是:%.2f\n", hy);
break;
}
}
return 0;
}
1.
#include <stdio.h>
int main()
{
int i;
float money = 4000000;
for (i = 1; ; i++)
{
money -= 500000;
money += money * 0.08;
if (money < 0)
{
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如
洗。。。\n", i);
break;
}
}
return 0;
}
2.
3.
#include <stdio.h>
int main()
{
long a = 1, b = 1, c, i;
for (i = 3; i <= 24; i++)
{
c = a + b;
a = b;
b = c;
}
printf("两年后,共有%ld对兔子。\n", c);
return 0;
}
|
|