北觅 发表于 2021-9-24 11:13:17

if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
}
else{
bill = cost * flag;}

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

junran 发表于 2021-9-24 14:03:37

1

774461657 发表于 2021-9-24 21:08:27

1

chok_sou 发表于 2021-9-25 09:46:55

加油

Lijjsk 发表于 2021-9-25 10:25:18

快乐

lovejj 发表于 2021-9-25 11:17:58

0.100个
1.10个
2.a
3.??????
4.x > 0 && z = x || x < 0 && z = -x
5.
    if (size > 12)
    {
            cost = cost * 1.05;
            flag = 2;
    }
    bill = cost * flag;

ssjmhh56 发表于 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) 求和

13715930237 发表于 2021-9-25 15:03:15

q

清宜2 发表于 2021-9-25 18:33:10

0.10个A
1.9个B
2.c
3.b=5,c=9
4.x>0?x:|x|
5.

857142 发表于 2021-9-25 18:59:56

666

安东尼11 发表于 2021-9-25 22:34:27

0

wang_jf 发表于 2021-9-25 23:15:17

....

雾隐花川夜 发表于 2021-9-25 23:41:00

6666666666666

xhynb 发表于 2021-9-25 23:54:09

DA

Sue. 发表于 2021-9-26 16:44:53

1

宫村伊澄 发表于 2021-9-26 17:06:07

答案

惘蝤蛴 发表于 2021-9-26 18:22:40

0:10个
1:10个
2:a
3:a = 14,b = 3,c = 9

0:#include <stdio.h>

int main()
{
        int a = 10000, b = 10000, year = 0;
        float i = a, j = b;
       
        while(i >= j)
        {
                i = i + a * 0.1;
                j = j * (1 + 0.05);
                year++;
        }
       
        printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
        printf("小甲鱼的投资额是:%.2f\n", i);
        printf("黑夜的投资额是:%.2f\n", j);
       
        return 0;
}

1:#include <stdio.h>

int main()
{
        int a = 4000000, b = 500000, year = 1;
        float i = a - b;
       
        while (i > 0)
        {
                year++;
                i = i * (1 + 0.08) - b;
        }
       
        printf("%d年后,小甲鱼败光了所有的家产,再次回到一贫如洗!\n", year);
       
        return 0;
}

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

int main()
{
        int i = 1, j = 1, n = 2;
        float pi = 1;
       
        while(fabs(j) > pow(10, -8))
        {
                if(n % 2 == 0)
                {
                        i = -(i + 2);
                }
                else
                {
                        i = i + 2;
                }
                j = 1 / i;
                pi = pi + j;
                n++;
        }
       
        printf("Π= %.7f", pi);
       
        return 0;
}

一时学习一时爽 发表于 2021-9-26 18:52:34

学习

武sdd 发表于 2021-9-27 18:36:00

0.10
1.0
2
3.b=4,c=10
4.z=x>0?x:-x
5.if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
}
else
{
    bill = cost * flag;
}

Ais0329 发表于 2021-9-27 20:32:36

1
页: 181 182 183 184 185 186 187 188 189 190 [191] 192 193 194 195 196 197 198 199 200
查看完整版本: S1E16:拾遗 | 课后测试题及答案