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

tljoe 发表于 2019-1-5 23:28:43

1

culifoo 发表于 2019-1-6 13:33:57

怪咖野牛 发表于 2019-1-6 15:50:59

6666

a3979897 发表于 2019-1-6 18:39:59

喜羊羊Vinnie 发表于 2019-1-8 02:08:22

文体两开花

fishpoke 发表于 2019-1-9 12:26:52

0.
81

1.
8

2.
a

3.

4.
x>0?x:-x

5.
if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
}
else
{
      bill = cost * flag;
}
---
if (ibex > 14)
{
      sheds = 3;
}
else
{
      sheds = 2
      help = 2 * sheds;
}
----

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

----

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

int main()
{
      double money = 10000;
      double fish;
      double black;
      int year;

      for (year=1;year<100;year++)
      {
                fish = money + money*0.1*year;
                black = 10000*pow(1.05,year);

                if (black>fish)
                {
                        printf("after %d year black >fish\n",year);
                        printf("fish = %.2f \n",fish);
                        printf("black = %.2f \n",black);
                        break;
                }
      }

}

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

int main()
{

      double fish=4000000;
      int year;

      for (year=1;year<100;year++)
      {
                fish = fish*1.08;
                if (fish<0)
                {
                        printf("after %d year \n",year);
                        //printf("fish = %.2f \n",fish);
                        break;
                }
                fish = fish-500000;

      }

}

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

int main()
{
      double number;
      int i,j;
      for(i=3;i<1000;i++)
      {
                j=1;
                number = 1;
                if(j%2!=0)
                {
                        number = number - (1/(double)i);
                }
                else
                {
                        number = number + (1/(double)i);
                }
               
                if(number)
                j++;
                i++;

                printf("%.5f\n",number);

      }

}
---------

wtb18951101 发表于 2019-1-10 14:30:51

1

Nuri 发表于 2019-1-10 17:38:53

123

jxp425 发表于 2019-1-11 13:28:00

kaka

sophisticated 发表于 2019-1-11 17:31:03

感谢分享

心镜如一TYB 发表于 2019-1-12 23:34:53

2019年1月12日 10:34:49

xieyx2003 发表于 2019-1-14 19:26:15

这个有意思

FE0636556 发表于 2019-1-14 21:44:26

qqq

aaa4d56 发表于 2019-1-14 22:48:00

I love FishC.com!

荆皎 发表于 2019-1-14 23:02:29

a

兔子TUZI 发表于 2019-1-15 09:44:28

1

牛奶刺身 发表于 2019-1-16 19:15:20

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