0.10
1.11
2.a,b,c
3.a=14,b=4,c=10
4.z = x>=0?x:-x
5.Aif (size > 12)
{
cost = cost * 1.05;
flag =2;
}
bill = cost * flag;
Bsheds = 2;
if (ibex > 14)
{
sheds = 3;
}
help = 2 * sheds;
Cwhile (scanf("%d", &score) == 1)
{
if (score < 0)
{
break;
}
count++;
}
printf("count = %d\n", count);
0.#include <stdio.h>
#include <math.h>
main()
{
double xjy, hy;
int year;
for (year=1;;year++)
{
xjy = 10000 * 0.1 * year + 10000;
hy = 10000 * pow(1+0.05, year);
if (hy>xjy)
{
break;
}
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
printf("小甲鱼的投资额是:%.2f\n", xjy);
printf("黑夜的投资额是:%.2f\n", hy);
return 0;
}
1.#include <stdio.h>
int main()
{
double money = 400.0;
int year = 0;
while (1)
{
year++;
money = money * (1 + 0.08) - 50;
if (money < 0)
{
break;
}
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗...\n", year);
return 0;
}
2.#include <stdio.h>
int main()
{
double pi = 0;
int num;
double temp;
for (num =1;;num++)
{
temp = 1.0 / (2 * num -1);
if (temp<0.00000001)
{
break;
}
if (num % 2 == 0)
{
pi = pi - temp;
}
else
{
pi = pi + temp;
}
}
pi= 4*pi;
printf("pi=%.7f",pi);
return 0;
}
3.#include <stdio.h>
int main()
{
int month, last, now, temp;
for (last = 0, now = 1, month =1;month <= 24;month++)
{
temp = now;
now = now + last;
last = temp;
}
printf("%d", now);
return 0;
}
|