0.
10次,外循环地哦啊见不满足;
1.
不会打印
2.cba
3.
a = 12
b = 4
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.do
{
scanf("%d", &score);
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
}
while (1)
0.#include <stdio.h>
int main()
{
float sum_fish = 10000, sum_black = 10000;
int year;
_Bool flag;
for (year = 0; sum_fish >= sum_black; year++)
{
sum_fish += 1000;
sum_black = 1.05 * sum_black;
}
printf("%d年后,黑夜的投资额超过了小甲鱼!\n小甲鱼的投资额是:%.2f\n黑夜的投资额是:%.2f\n", year, sum_fish, sum_black);
return 0;
}
1.#include <stdio.h>
int main()
{
double total = 4000000;
int amount = 500000, year = 0;
while (total >= 0)
{
total -= amount;
total = 1.08 * total;
year++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", year);
return 0;
}
2.#include <stdio.h>
#include <math.h>
int main()
{
double pi = 0, i = 1;
long long deno;
for (deno = 1; i / fabs(deno) > pow(10, -8); deno = -deno)
{
pi += i / deno;
deno = fabs(deno) + 2;
}
pi = 4 * pi;
printf("计算结果为:%.7f\n", pi);
return 0;
}
(不知道为什么结果不对)
3./*初始2只(qty),time为24,出生的第一对兔子假定在time为1的时候出生,故其在
* time为3的时候才可以生育;所以兔子可以存放在三个变量中
* (出生initial,发育grow,成熟breed)
* 每当time变化的时候三个变量随之变化,即当time为n的时候,
* initial(n) = breed(n-1), grow(n) = initial(n-1), bread = grow(n-1) + bread(n-1);*/
#include <stdio.h>
int main()
{
int time, initial = 0, grow = 0, bread = 2, temp;
for (time = 0; time < 24; time++)
{
temp = grow;
grow = initial;
initial = bread;
bread += temp;
}
printf("%d个月后,兔子的总数达到了%d只!\n", time, initial + grow + bread);
return 0;
}
|