|
发表于 2018-3-15 12:37:58
|
显示全部楼层
0. 100次。
1. 10次。
2. a, b, c
3. b == 3, c == 8; a == 5
4. z = x >= - x ? : x, -x;
5.
A:
if (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
B:
if (ibex > 14)
{
sheds = 3;
}
else
{
sheds = 2;
}
help = 2 * sheds;
C:
while(1)
{
readin:scanf("%d", &score);
if (score < 0)
{
break;
}
count++;
}
printf("count = %d\n", count);
动动手:
0.
#include <stdio.h>
#include <math.h>
int main()
{
float xjy, hy;
int i;
for (i = 1; ; i++)
{
xjy = 10000 + i * 10000 * 0.1;
hy = 10000 * pow((1 + 0.05), i);
if (hy > xjy)
{
break;
}
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n", i);
printf("小甲鱼的投资额是:%.2f\n", xjy);
printf("黑夜的投资额是:%.2f\n", hy);
return 0;
}
1.
#include <stdio.h>
int main()
{
int i;
float mon = 400;
for(i = 1; ; i++)
{
mon = mon - 50;
if (mon < 0)
{
break;
}
else
{
mon = mon * (1 + 0.08);
}
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", i);
return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
float sum = 1, temp;
int i;
for (i = 2; ; i++)
{
temp = 1.0 / (2 * i - 1);
if (temp < pow(10, -8) / 4)
{
break;
}
if (i % 2 == 0)
{
temp = -temp;
}
sum = sum + temp;
}
sum = 4 * sum;
printf("Pi的近似值是:%.7f\n", sum);
printf("10^-8是:%.11f\n i = %d\n", pow(10, -8), i);
printf("temp是:%.11f\n", temp);
return 0;
}
3.
#include <stdio.h>
int main()
{
int i, sum = 1;
for (i = 2; i <= 24; i++)
{
sum = sum + (24 - i);
}
printf("两年之后有%d对兔子\n", sum);
return;
}
|
|