Sun-zY-Yang 发表于 2018-12-17 21:31:25

q

纵横天下3 发表于 2018-12-18 19:17:30

answer

Joyong 发表于 2018-12-20 15:45:40

1. 10
2. i = 11时, 执行goto label ,然后退出。10次
3. a = 5, b = 5, c = 5
4. a = (b = 3, 4, c = 9 , 14)
5.if (size>12)
{
        cost = cost * 1.o05;
                flag = 2;
}
else
{
        bill = cost * flag;
}

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

轻鱼 发表于 2018-12-20 22:38:07

1

1809228982 发表于 2018-12-22 10:57:14

哈哈

davidcq 发表于 2018-12-23 21:35:42

看看

我叫MD 发表于 2018-12-24 19:26:52

0.打印100次
1.打印10次
2.a = 5;
b = 5;
c = 5;
3.b == 5;c == 9; a = 14
4.z = x > 0 ? x : -x

sign 发表于 2018-12-25 14:50:28

0.10
1.0
2.a
3.a=14;b=5;c=9
4.if(-x > 0){z = x;}
   else{z = x - 2x;}
5.A.if(size > 12){cost = 1 * 1.05;flag = 2;}
      else{bill = cost * flag;}
   B.if(ibex > 14){sheds = 3;}
      else{sheds = 2;help = 2 * sheds;}
   C.if(score < 0){printf("count = %d\n",count);
      else{count++;scanf("%d",&score);

mm为了你 发表于 2018-12-26 11:45:15

{:5_105:}

wyr190615 发表于 2018-12-26 13:57:51

111

resail 发表于 2018-12-27 18:05:52

0. 100次
1. 不打印
2. a b c
3. 14 5 9
4. z = x > 0?x : -x;
5.
if (size > 12)
{
    cost = cost * 1.05;
    flag = 2;
}
bill = cost * flag;

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

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

0.
#include <stdio.h>

#define XJY 0.1
#define HY 0.05

int main()
{
    int year = 0;
    float xjy_money, hy_money;
    xjy_money = hy_money = 10000;

    do{
            year++;
      xjy_money += 10000 * XJY;
      hy_money = hy_money * (1 + HY);
    }while (xjy_money >= hy_money);

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

1.
#include <stdio.h>

#define LI 1.08
#define QU 50.0

int main()
{
    float surplus = 400.0;
    int year = 0;

    do{
      year++;
      surplus -= QU;
      surplus *= LI;
    }while (surplus >= 50);

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

2.
#include <math.h>

int main()
{
    double Pi = 0, i = 1;
    while (fabs(1 / i) > pow((double)10, -8)){
      Pi += 1 / i;
      i = i < 0? -i + 2 : -(i + 2);
    }
    printf("%.7f\n", Pi);
    return 0;
}

3.
#include <stdio.h>

int main()
{
    long sum = 0, i = 1, j = 2, temp;
    int time = 3;
    for (; time <= 24; time++){
      sum = i + j;
      temp = j;
      j = sum;
      i = temp;
    }

    printf("震惊!2年后有%ld对兔子!\n", sum);
    return 0;
}

金光上人 发表于 2018-12-28 10:26:30

42

YanzzZ 发表于 2018-12-28 14:41:55

1

PLGR146 发表于 2018-12-29 22:32:40

0.100
1.11
2.a b c
3.14
4.x>0 ? z = x; z = -x;
5.A.        if (size > 12)
{
cost = cost * 1.05;
flag = 2;
      bill = cost * flag;
}
bill = cost * flag;
B:        if (ibex > 14)
{
sheds = 3;
help = 2 * sheds;
}
else
{
shed = 2;
help = 2 * sheds;
}
C:    scanf("%d", &score);
while (score < 0)
{
if (score < 0)
{
printf("count = %d\n", count);
}
else
{
count++
}

0.
#include <stdio.h>
#define mian main
int mian()
{
    double xjy;
    double hyt;
    double xjyt;
    int year = 0;
   
    for (xjyt = hyt = xjy = 10000; hyt <= xjyt; year++)
    {
      xjyt = xjyt + xjy * 0.1;
      hyt = hyt + hyt * 0.05;
    }
   
    printf("%d年后,黑夜的投资额超过小甲鱼!\n小甲鱼的投资额是:%.2f\n黑夜的投资额是:%.2f\n", year, xjyt, hyt);
    return 0;
}
1.#include <stdio.h>
#include <math.h>
#define mian main
int mian()
{
        double xjy = 400;
        int year = 0;

        for (xjy = 400; xjy > 0; year++)
        {
                xjy = xjy - 50 + (xjy - 50) * 0.08;
        }

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

        system("pause");
        return 0;
}

2.#include <stdio.h>
#include <math.h>
#define mian main
int mian()
{
        double pi = 0;
        double j = 1;
        double i;

        for (i = 1; fabs(1 / i) > pow(10, -8);)
        {
                pi = pi + 1 / i;
                i = (i > 0) ? -(i + 2) : -i + 2;
                //printf("%.10f %f\n", pi, i);
        }

        pi = 4 * pi;
        printf("%.7f\n", pi);

        system("pause");
        return 0;
}

3.#include <stdio.h>
#include <math.h>
#define mian main
int mian()
{
        int tz = 1;
       
        for (int mt = 1; mt <= 24; mt++)
        {
                tz = tz * 2;
        }

        printf("假设所有兔子都不会死去,能够一直干下去,两年之后可以繁殖%d只兔子\n", tz);

        system("pause");
        return 0;
}

蓝漠花海 发表于 2018-12-29 22:57:01

π....求不出来

俞瑾迦 发表于 2018-12-30 16:08:30

emmmmmmmm

ahr123 发表于 2018-12-30 20:55:17

1

huangxiaohuang 发表于 2019-1-2 13:14:20

0        9个或者0个,在第一层循环中循环条件是j!=10,但是没有对j初始化,如果碰巧j就是10,那就是0次,否则进入第二层循环,循环十次并且循环结束j=10.

1        0个
2        c b a
3        a14   b5   c9
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;
        }
        else
        {
                sheds = 2;
        }

        help = 2 * sheds;

        C:
        while(1)
        {
                scanf("%d", &score);
                if(score < 0)
                {
                        printf("count = %d\n", count);
                        break;
                }
                count++;
        }
       
#include <stdio.h>
#include <stdio.h>

int main()
{
    double money = 1000, moneyJ, moneyH;
    int year = 1;
    float p1 = 10.0 / 100, p2 = 1 + 5.0 / 100;
    for (year; ; year++)
    {
      moneyJ = money + money * p1 * year;
      moneyH = money * pow(p2, year);

      if(moneyJ >= moneyH)
      {
            continue;
      }
      break;
    }
   
    printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
    printf("小甲鱼的投资额是:%.2f\n", moneyJ);
    printf("黑夜的投资额是:%.2f\n", moneyH);

    return 0;
}

#include <stdio.h>

int main()
{
    double money = 4000000, cost = 500000, p = 8.0 / 100;
    int year = 0;

    while(money > 0)
    {
      money -= cost;
      money *= (1 + p);
      year++;
   
    }
   
    printf("%d年后,小甲鱼败光了所有的家产,再次变得一贫如洗......\n", year);

    return 0;
}

#include <stdio.h>
#include <stdio.h>

int main()
{
    double pi = 0.0, i;
    int n = 1;
    do
    {
      i = pow (-1, (n-1)) / (2 * n - 1);
      pi = pi + i * 4;
      n++;

    } while (fabs(i) >= pow(10, -8));

    printf("Pi精确到小数点后七位的近似值是:%.7lf\n", pi);
}

dddzy 发表于 2019-1-4 00:10:56

2

SNADO 发表于 2019-1-4 21:34:17

I Love FishC.com
页: 26 27 28 29 30 31 32 33 34 35 [36] 37 38 39 40 41 42 43 44 45
查看完整版本: S1E16:拾遗 | 课后测试题及答案