|
发表于 2021-3-31 22:21:36
|
显示全部楼层
测试题:
0:10
1:10
2:a b c d
3:
4:
A: if(x < 0)
{
z = (-x);
}
else{
z = x;
}
5:
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:
do{
readin: scanf("%d", &score);
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
}while(1);
动动手:
0:
#include <stdio.h>
int main()
{
int i;
double prince1 = 0.10, prince2 = 0.05, capital1, capital2, total1, total2 ;
capital1 = 10000;
capital2 = 10000;
for(i = 1;; i ++)
{
total1 = i * prince1 * capital1 + capital1;
total2 = prince2 * capital2 + capital2;
capital2 = total2;
if(total1 < total2)
{
break;
}
}
printf("%d年后黑夜的存款超过小甲鱼\n", i);
printf("此时小甲鱼的存款为%.2f!\n", total1);
printf("此时黑夜的存款为:%.2f\n", total2);
return 0;
}
1:
#include <stdio.h>
int main()
{
int i;
long double prince1 = 0.10, prince = 0.08, capital1, capital2, total, total2 ;
total = 4000000;
for(i = 1;1; i ++)
{
total = total - 500000;
total = total * prince + total;
if(total <= 0)
{
break;
}
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗", i);
return 0;
}
2:
|
|