#include <stdio.h>
int main()
{
float fish = 10000, blake = 10000;
int yers = 0;
do
{
fish = fish + 10000 * 0.1;
blake = blake + blake * 0.05;
yers = yers++;
}
while (blake < fish);
printf("%.d年后,黑夜的投资额超过小甲鱼!\n", yers);
printf("小甲鱼的投资额是:%.2f\n", fish);
printf("黑夜的投资额是:%.2f\n", blake);
}
#include <stdio.h>
int main()
{
int fish = 4000000, lx;
int cout = 0;
while (fish > 0)
{
fish = (fish - 500000) + fish * 0.08;
cout++;
}
printf("%d年之后,小甲鱼败光了所有家产,再次回到一贫如洗......\n",cout);
}
#include <stdio.h>
int main()
{
int m;
int f1 = 1, f2 = 1, fn;
int count = 1;
for(m = 1; m <= 24; m++)
{
fn = f1 + f2;
printf("第%d个月共有%d\n", count, fn);
f1 = f2;
f2 = fn;
count++ ;
}
printf("两年后一共繁殖%d只兔子\n", fn);
}
|