|
发表于 2023-2-21 10:46:24
|
显示全部楼层
0.10
1.0
2.a, b, c
3.
a = 14
b = 5
c = 9
4.x >= 0 ? x : -x
5.
A
if (size > 12) {
cost *= 1.05;
flag = 2;
} else {
bill *= flag;
}
B
if (ibex > 14) {
sheds = 3;
}
sheds = 2;
help = 2 * sheds;
C
scanf("%d", &score);
if (score < 0) {
printf("count = %d\n", count);
} else {
count++;
scanf("%d", &score);
printf("count = %d\n", count);
}
0.
#include <stdio.h>
#include <math.h>
int main() {
double xjy, xjyb, hyb, hy;
hy = xjy = 0;
xjyb = hyb = 10000;
int year = 0;
while (xjy >= hy) {
xjy = xjyb + (xjyb * 0.1) * (year + 1);
hy = hyb * pow(1 + 0.05, year + 1);
year++;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n\
小甲鱼的投资额是:%.2lf\n\
黑夜的投资额是:%.2lf", year, xjy, hy);
return 0;
}
1.
#include <stdio.h>
int main() {
double sum;
sum = 4000000;
int year;
year = 0;
while (sum >= 0) {
sum = sum + 4000000 * 0.08 * (year + 1) - 500000 * (year + 1);
year++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……", year);
return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main() {
double sum;
sum = 0;
double i, x;
i = x = 1;
while (fabs(i / x) >= pow(10, -8)) {
sum += i / x;
i = -i;
x += 2;
}
printf("%.7lf", sum * 4 );
return 0;
}
3.
#include <stdio.h>
int main() {
long long x, month;
x = 2;
for (month = 1; month <= 24; month++) {
x += 2;
}
printf("两年之后可以繁殖%lld对兔子", x / 2);
return 0;
}
|
|