|
发表于 2021-9-25 13:50:50
|
显示全部楼层
0. 100
1. 10
2. a, b, c
3. a = 14, b = 5, c = 9
4. z = x>=0?sqrt(x):0
5. if (size > 12) {
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
5.1. if (ibex > 14){
sheds = 3;
}
sheds = 2
help = 2 * sheds;
5.2. while (score < 0){
printf("count = %d\n", count);
count++
scanf("%d", &score);
}
5.3 #include <stdio.h>
int main(int argc, char *argv[]) {
int score = 0, count = 0;
while (1) {
scanf("%d", &score);
if (score < 0) {
printf("count=%d\n", count);
return 0;
}
count++;
}
return 0;
}
0. #include <stdio.h>
int main(int argc, char *argv[]) {
float start = 10000;
float c_total = start, h_total = start;
float s_rate = 0.1, c_rate = 0.05;
int count;
while (c_total >= h_total) {
c_total += start * s_rate;
h_total = h_total * (1 + c_rate);
count++;
}
printf("%d年后, 黑夜超过小甲鱼!", count);
printf("小甲鱼投资额度: %.2f\n", c_total);
printf("黑夜投资额度: %.2f\n", h_total);
return 0;
}
1. #include <stdio.h>
int main(int argc, char *argv[]) {
float money = 400, spend = 50;
float rate = 0.08;
int count;
while (money >= 0) {
money -= spend;
money += money * rate;
count++;
}
printf("%d年之后, 破产...", count);
return 0;
}
2.
3. 2^(n-1) 求和 |
|