0.100
1.11
2.a b c
3.14
4.x>0 ? z = x; z = -x;
5.A. if (size > 12)
{
cost = cost * 1.05;
flag = 2;
bill = cost * flag;
}
bill = cost * flag;
B: if (ibex > 14)
{
sheds = 3;
help = 2 * sheds;
}
else
{
shed = 2;
help = 2 * sheds;
}
C: scanf("%d", &score);
while (score < 0)
{
if (score < 0)
{
printf("count = %d\n", count);
}
else
{
count++
}
0.#include <stdio.h>
#define mian main
int mian()
{
double xjy;
double hyt;
double xjyt;
int year = 0;
for (xjyt = hyt = xjy = 10000; hyt <= xjyt; year++)
{
xjyt = xjyt + xjy * 0.1;
hyt = hyt + hyt * 0.05;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n小甲鱼的投资额是:%.2f\n黑夜的投资额是:%.2f\n", year, xjyt, hyt);
return 0;
}
1.#include <stdio.h>
#include <math.h>
#define mian main
int mian()
{
double xjy = 400;
int year = 0;
for (xjy = 400; xjy > 0; year++)
{
xjy = xjy - 50 + (xjy - 50) * 0.08;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗...\n", year);
system("pause");
return 0;
}
2.#include <stdio.h>
#include <math.h>
#define mian main
int mian()
{
double pi = 0;
double j = 1;
double i;
for (i = 1; fabs(1 / i) > pow(10, -8);)
{
pi = pi + 1 / i;
i = (i > 0) ? -(i + 2) : -i + 2;
//printf("%.10f %f\n", pi, i);
}
pi = 4 * pi;
printf("%.7f\n", pi);
system("pause");
return 0;
}
3.#include <stdio.h>
#include <math.h>
#define mian main
int mian()
{
int tz = 1;
for (int mt = 1; mt <= 24; mt++)
{
tz = tz * 2;
}
printf("假设所有兔子都不会死去,能够一直干下去,两年之后可以繁殖%d只兔子\n", tz);
system("pause");
return 0;
}
|