text
0. 100
1. 11
2. a b c
3. a= 12, b= 3, c=8
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;
}
else{
help = 2 * sheds;
}
sheds = 2;
C.while(1)
{
scanf("%d", &score);
if (score < 0)
{
printf("count = %d\n", count);
break;
}
else
{
count++;
}
}
hand
0.#include <stdio.h>
int main()
{
int fish = 0, black = 10000, year = 1;
float sum_b = 10000.00, sum_f = 0.00;
while (1)
{
fish = 10000 * 0.1 + fish;
sum_f = 10000 + fish;
sum_b = sum_b * 1.05;
if (sum_b > sum_f)
{
printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
printf("小甲鱼的投资额是:%.2f\n", sum_f);
printf("黑夜的投资额是:%.2f\n", sum_b);
break;
}
year++;
}
return 0;
}
1.#include <stdio.h>
int main()
{
float money = 4000000;
int year = 0;
while (1)
{
money = money - 500000;
money = money * 1.08;
year++;
if (money <= 0)
{
printf("%d年后,小甲鱼败光了所有的家产\n", year);
break;
}
}
return 0;
}
2.#include <stdio.h>
#include <math.h>
int main()
{
double i = 1, b = 1, pi = 0, c = 0;
while (1)
{
c = i / b;
pi = c + pi;
i = -i;
b += 2;
if (fabs(c)<=pow(10, -8))
{
pi = pi * 4;
printf("圆周率为:%.7lf\n", pi);
break;
}
}
}
3.#include <stdio.h>
int main()
{
long int one_month = 1, two_month = 0, month, sum = 0;
for(month = 1; month <= 24; month++)
{
sum = one_month + two_month;
one_month = two_month;
two_month = sum;
}
printf("两年后兔子总数为%ld\n", sum);
return 0;
}
|