0 0或10
1 0
2 a b c
3 14 5 9
4 z = ( x>0 ? x : -x)
5Aif (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
Bif (ibex > 14)
{
sheds = 3;
}
else
{
sheds = 2;
}
help = 2 * sheds;
Cif (score < 0)
{
printf("count = %d\n", count);
}
count++;
scanf("%d", &score);
0#include <stdio.h>
int main()
{
float a=10000,b=10000,c=10000;
int year=0;
do
{
a = a + c * 0.1;
b = b * (1 + 0.05);
year++;
}
while(a>=b);
printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
printf("小甲鱼的投资额是:%.2f\n", a);
printf("黑夜的投资额是:%.2f\n", b);
return 0;
}
1#include <stdio.h>
int main()
{
int year = 0;
long long a = 4000000;
do
{
a = (a - 500000) * 1.08 ;
year++;
}
while(!(a < 0));
printf("%d年以后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", year);
return 0;
}
2(算了7秒钟,并且是3.1415927,毕竟第8位是数字5)#include <stdio.h>
#include <math.h>
int main()
{
double a = 1, pi = 1;
unsigned long long b = 1;
int m = 1;
do
{
b = b + 2;
a = pow(-1, m) / b;
pi = pi + a;
m = m + 1;
}
while(b < 100000000);
pi = pi * 4;
printf("pi = %.7f", pi);
return 0;
}
3(近亲繁殖会出问题的) #include <stdio.h>
int main()
{
int a = 1, b = 0, c = 0, t, month = 1; //能生殖的,差1个月的,差2个月的,用来交换量的,月份
for( ; month <= 12; month++)
{
t = a;
a = a + b;
b = c;
c = t;
}
printf("两年后有%d只兔子\n", 2 * (a + b + c));
return 0;
}
总共258只 |