|
发表于 2022-12-2 21:07:15
|
显示全部楼层
问答题答案:
0. 100
1. 10
2. a, b, c
3. 14
4.
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.
- scanf("%d", &score);
- if(score < 0){
- printf("count %d\n", count);
- }else {
- count++;
- }
复制代码
动动手答案:
0.
- #include <stdio.h>
- #include <math.h>
- int main(){
- int corpus = 10000;
- // money1 小甲鱼投资额,money2 黑夜投资额
- double money1 = 0, money2 = 0;
- printf("%.2f %.2f\n", money1, money2);
- int count = 1;
- while (1){
- money1 = (count * 0.1 * corpus) + corpus;
- money2 = corpus * pow(1 + 0.05, count);
- if(money2 > money1){
- break;
- }
- count++;
- }
- printf("%d年后,黑夜的投资额超过小甲鱼!\n", count);
- printf("小甲鱼的投资额是:%.2f\n", money1);
- printf("黑夜的投资额是:%.2f\n", money2);
- return 0;
- }
复制代码
1.
- #include <stdio.h>
- int main(){
- int count = 0;
- double money = 4000000, temp;
-
- while (money >= 0) {
- count++;
- temp = money - 500000;
- money = temp + temp * 0.08;
- }
- printf("%d年之后,小甲鱼败光了所有的家产,再次回到一瓶如洗......\n", count);
- return 0;
- }
复制代码
2.
3.
- #include <stdio.h>
- int main(){
- int x = 1, y = 1, temp;
- int i;
- for (i = 2; i <= 24; i++){
- temp = x + y;
- x = y;
- y = temp;
- }
- printf("兔子在两年后能繁殖%d对兔子\n", y);
- return 0;
-
- }
复制代码
|
|