|
发表于 2020-10-23 22:33:50
|
显示全部楼层
0. 10
1. 0
2. 5
3.
a = 14
b = 5
c = 9
4.
#include <stdio.h>
int main()
{
int x, z;
scanf("%d", &x);
z = x > 0 ? x : -x;
printf("%d", z);
return 0;
}
5.
A.
if (size > 12)
{
cost *= 1.05;
flag = 2;
}
bill = cost * flag;
B.
if (ibex > 14)
{
sheds = 3;
}
sheds = 2;
help = 2 * sheds;
C.
while (1)
{
readin: scanf("%d", &score);
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
}
0.
#include <stdio.h>
int main()
{
int time, a = 10000, b = 10000;
double sa = a, sb = b;
for (b, sb; sb <= sa; time++)
{
sa += a * 0.1;
sb += sb * 0.05;
}
printf("%d年后超过\nA投资额是%.2f\nB投资额是%.2f", time, sa, sb);
}
1.
#include <stdio.h>
int main()
{
double a = 400;
int year;
for (a; a > 0; year++)
{
a = a * 1.08 - 50;
}
printf("%d年后没钱", year);
return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
double PI, a = 1.0000000;
int i = 1;
for (PI, a, i; fabs(a) > 1.0E-8;)
{
a = 1.0000000 / i;
PI += a;
i = -(i + 2 );
}
printf("Π的值约等于%.7f", PI);
return 0;
}
3.
#include <stdio.h>
int main()
{
int b = 2, t, i, s = 0;
for (b, s, t; i < 24; i++)
{
t = b + s;
b += s;
s = t;
}
printf("兔子数量为%d", b + s);
return 0;
} |
|