krystal-fan 发表于 2019-2-20 13:59:16

{:10_261:}

chenzhou 发表于 2019-2-20 17:42:54

{:5_90:}

HVERAGIOW 发表于 2019-2-20 18:15:03

0.10个
1.11个
2.a,b,c
3.a=14,b=5,c=9
4.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;
}
elae
{
        sheds = 2;
}

help = 2 * sheds;
C.
while(1)
{
        scanf("%d", &score);
        if (score < 0)
        {
                      printf("count = %d\n", count);
                break;
        }
        count++;
}

0.
#include<stdio.h>

#define PRINCIPAL 10000
#define INTEREST_S 0.1
#define INTEREST_C 0.05

int main()
{
        int year;
        double pri_fish = PRINCIPAL,pri_night = PRINCIPAL;

        for(year = 0; pri_fish >= pri_night; year++)
        {
                pri_fish = PRINCIPAL * (1 + (year + 1) * INTEREST_S);
                pri_night += pri_night * INTEREST_C;
        }

        printf("%d年后,黑夜的投资额超过小甲鱼!\n",year);
        printf("小甲鱼的投资额是:%.2f\n",pri_fish);
        printf("黑夜的投资额是:%.2f\n",pri_night);

        return 0;
}
1.
#include<stdio.h>

#define PRINCIPAL 4000000
#define COST 500000
#define INTEREST 0.08

int main()
{
        int year;
        double price = PRINCIPAL;

        for(year = 0; price > 0; year++)
        {
                price -= COST;
                price += price * INTEREST;
        }

        printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗...\n",year);

        return 0;
}
2.
#include<stdio.h>
#include<math.h>

int main()
{
        int i = 1;
        double pi = 0,n = 1,f = pow(10,-8);

        while(fabs(n) >= f)
        {
                pi += n;
                n = pow(-1,i) * 1.0 / (2 * i + 1);
                i++;
        }

        printf("PI 的小数点后7位近似值位:%.7f\n",4 * pi);

        return 0;
}
3.
#include<stdio.h>

#define year 2

int main()
{
        int month,twain1 = 1,twain2 = 1,temp;

        for(month = 3; month <= 12 * year; month++)
        {
                temp = twain2;
                twain2 += twain1;
                twain1 = temp;
        }

        printf("两年后有%d对兔子。\n",twain2);

        return 0;
}

ws000202 发表于 2019-2-21 01:41:31

回复查看参考答案

小白要成长 发表于 2019-2-21 20:55:13

156

忘忧草W-W 发表于 2019-2-22 10:58:49

答案

ljyy20000102 发表于 2019-2-22 16:23:06

我想知道答案

星落无痕 发表于 2019-2-22 20:27:29

0、100个
1、9个
2、a = b = c
3、a = 14, b = 5, c = 9
4、z = x < 0? -x : x
5、
A.
if(size > 12)
{
   cost = cpst * 1.05;
   flag = 2;
}

bill = cost * flag;

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

sheds = 2;
help = 2 * sheds;

C.
while(score >= 0)
{
    count++;
    scanf("%d", &score);
}

printf("count = %d\n", count);

machunfeng1991 发表于 2019-2-22 22:02:48

回复

Irelian 发表于 2019-2-23 10:06:01

123

伯劳劳 发表于 2019-2-26 13:32:39

{:10_323:}

极力 发表于 2019-2-27 17:02:51


谢谢楼主

GumpYu 发表于 2019-2-27 19:25:54

本帖最后由 GumpYu 于 2019-2-27 19:35 编辑

0:10
1:0(while 取值为0不会执行)
2: 全部都是
3: a = 14,b=9, c=5
4:x>0?x:-x;
5:if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
}
bill = cost * flag;


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

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




无所事事的147 发表于 2019-2-28 10:13:51

看答案

13133553675 发表于 2019-2-28 10:25:12

100

KENT000107 发表于 2019-2-28 17:41:48

……

提提提 发表于 2019-3-2 15:19:59

{:10_275:}

我是鱼鱼 发表于 2019-3-2 17:58:35

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

我们 发表于 2019-3-3 11:53:42

{:5_109:}

凉生西辞 发表于 2019-3-3 14:49:22

1
页: 30 31 32 33 34 35 36 37 38 39 [40] 41 42 43 44 45 46 47 48 49
查看完整版本: S1E16:拾遗 | 课后测试题及答案