TzOhNuGo 发表于 2022-4-18 10:41:14

鱼C牛!

ekufo 发表于 2022-4-18 23:30:32

100次

小花兔 发表于 2022-4-19 10:44:09

0.10
1.11
2.a
3.0
4.
5.

wlsinsin 发表于 2022-4-19 12:01:22

学习

cmdrmo 发表于 2022-4-19 19:15:00

dd

iun007 发表于 2022-4-20 09:36:32

1

卢本伟牛逼 发表于 2022-4-20 22:31:00

a

SHthenew 发表于 2022-4-21 00:20:55

本帖最后由 SHthenew 于 2022-4-21 00:39 编辑

0. 10次
1. 没有
2. a, b, c
3. 13, 4, 9(答案:14, 5, 9)
4. int z = x >= 0 ? x : -x
5.
A. if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
}
bill = cost * flag;

B. if (ibex > 14)
{
      sheds = 3;
}
sheds = 2;
help = 2 * sheds;

C. if (score < 0)
{
      printf("count = %d\n", count);
}
count++;
scanf("%d", &score);

0. #include <stdio.h>
#include <math.h>

int main()
{
    int init_money = 10000, year = 1;
    _Bool is_beyond = 0;
    float a_rate = 0.1, b_rate = 0.05;
    float a_total, b_total;

    while (!is_beyond)
    {
      a_total = init_money * (1 + a_rate * year);
      b_total = init_money * pow((1 + b_rate), year);

      if (b_total > a_total)
      {
            is_beyond = 1;
      }
      else
      {
            year++;
      }
    }

    printf("%d年后,b的投资额超过a!\n", year);
    printf("a的投资额是:%.2f\n", a_total);
    printf("b的投资额是:%.2f\n", b_total);

    return 0;
}

1. #include <stdio.h>
#include <math.h>


int main()
{
    int year = 0;
    _Bool isBreak = 0;
    float remainMoney = 4000000, rate = 0.08;

    while (!isBreak)
    {
      if (remainMoney > 0)
      {
            remainMoney = (remainMoney - 500000) * (1 + rate);
            year++;
      }
      else
      {
            isBreak = 1;
      }
      
    }
   
    printf("%d年后,我败光所有家产,再次回到一贫如洗……\n", year);

    return 0;
}

2. #include <stdio.h>
#include <math.h>

int main()
{
    double max = pow(10, -8), pi, temp, result;

    for (int i = 1; 1.0 / (2 * i - 1) > max; i++)
    {
      temp = i % 2 ? 1.0 / (2 * i - 1) : -(1.0 / (2 * i -1));
      result += temp;
    }

    pi = 4 * result;

    printf("pi的值为%.7f\n", pi);
   
    return 0;
}

3. #include <stdio.h>

int cacu(month)
{
    if (month == 0)
    {
      return 0;
    }
    else if (month == 1)
    {
      return 1;
    }
    else
    {
      return cacu(month - 1) + cacu(month - 2);
    }
   
}

int main()
{
    int result = cacu(24);
    printf("2年后一共有%d对兔子\n", result);
    return 0;
}

fwunai 发表于 2022-4-21 11:51:39

sad

救赎自我- 发表于 2022-4-21 20:44:01

1

lvdaye 发表于 2022-4-22 20:59:00

4

鱼鹰不吃鱼 发表于 2022-4-22 21:19:47

{:10_277:}

为男朋友学c++ 发表于 2022-4-23 15:42:42

.......好难

z310394543 发表于 2022-4-23 18:24:28

LEG 发表于 2022-4-23 20:55:26

111

xiaoy丶 发表于 2022-4-24 19:56:59

.

shi5486993 发表于 2022-4-24 23:01:17

加油

小鲸鱼Rx 发表于 2022-4-25 15:36:59

1

1599032468 发表于 2022-4-25 17:16:32

1

wangzecl 发表于 2022-4-25 22:48:59

答案
页: 215 216 217 218 219 220 221 222 223 224 [225] 226 227 228 229 230 231 232 233 234
查看完整版本: S1E16:拾遗 | 课后测试题及答案