landrow 发表于 2018-4-9 17:38:16

0.10
1.0
2.a
3.14,5, 9
4.        x = i>=0 ? i : -i;
5.//

动动手:
0.
#include <stdio.h>

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

1.
#include <stdio.h>

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

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

int main()
{
//        int i;
        double i,j,x,y,z;
       
        j = 1,x = 1,i = 1;
        z = fabs(1/j);
       
        for (j = 1;;j += 2)
        {
                if (j > 1)
                {
                        i = -i;
                        y = i*1/j;
                        x = x + y;
                        z = fabs(1/j);
                }
               
                if (z < 0.0000000001)
                        {
                                break;
                        }
        }
       
        printf("%.8lf\n",x*4);
       
        return 0;
}

4.

小滨00000 发表于 2018-4-10 10:00:28

dan

yangfan255 发表于 2018-4-10 13:08:27

又见兔子

velt 发表于 2018-4-10 15:00:57

写作业!

程小磊 发表于 2018-4-10 20:11:15

fishyu123 发表于 2018-4-12 10:21:44

看看答案

赵旭升 发表于 2018-4-12 21:45:20

回复

人造人 发表于 2018-4-12 23:48:58

看答案

Andy118052 发表于 2018-4-14 12:08:11

{:10_277:}

SalvationN 发表于 2018-4-14 22:52:18

0

BIGLUO 发表于 2018-4-15 00:17:40

引入一些兔子的天敌,就是不知道这个天敌会不会变成兔子

稻-草人 发表于 2018-4-15 12:11:23

no

左小柯 发表于 2018-4-19 12:28:45

好人一生平安

llovenova 发表于 2018-4-19 20:36:16

1

ALEXLAY 发表于 2018-4-20 19:37:23

{:10_254:}

易大大 发表于 2018-4-20 19:40:35

看答案

风雪飘飘 发表于 2018-4-22 12:32:13

//    //使用条件运算符求出变量x的绝对值,并存放到变量z中
//
//    float x,z;
//    int flag;
//   do{
//       printf("请输入浮点变量x的值:");
//
//       while(flag=scanf("%f",&x)){
//         z=(x>=0)?x:-x;
//         printf("x的绝对值为 %f\n",z);
//       }
//       getchar();
//
//   }while(!flag);

//5 换掉goto
    //A 原代码
//    if (size > 12)
//    {
//      goto a;
//    }
//    goto b;
//    a:      cost = cost * 1.05;
//    flag = 2;
//    b:      bill = cost * flag;
//
    //修改后的代码
//    if (size > 12)
//    {
//      cost = cost * 1.05;
//      flag = 2;
//    }else{
//      bill = cost * flag;
//    }

    //B 原代码
//    if (ibex > 14)
//    {
//      goto a;
//    }
//    sheds = 2;
//    goto b;
//    a:      sheds = 3;
//    b:      help = 2 * sheds;
    //修改后:
//    if (ibex > 14)
//    {
//      sheds = 3;
//
//    }else{
//      sheds = 2;
//    }
//    help = 2 * sheds;

    //C 原代码
//    readin: scanf("%d", &score);
//    if (score < 0)
//    {
//      goto stage2;
//    }
//    count++;
//    goto    readin;
//    stage2: printf("count = %d\n", count);

    //修改后
//    do{
//      scanf("%d", &score);
//      if (score < 0)
//      {
//            printf("count = %d\n", count);
//      }else{
//            count++;
//      }
//    }while(score>=0);


//action 0
//    double money_xjy=10000,money_hy=10000,invest_xjy=0,invest_hy=0;
//    int i=0;
//
//    do{
//      invest_xjy=invest_xjy+10000*0.1;
//      invest_hy=invest_hy+money_hy*0.05;
//      money_hy=money_hy+money_hy*0.05;
//
//      i++;
//
//    }while(invest_xjy>=invest_hy);
//
//    printf("%d年后,黑夜的投资额度将会超过小甲鱼!\n",i);
//    printf("小甲鱼的投资额度:%f\n",invest_xjy);
//    printf("黑夜的投资额度:%f\n",invest_hy);

//action 1
//    double money=4000000;
//    int time=0;
//    do{
//      money=money-500000;
//      money=money+money*0.08;
//      time++;
//
//    }while(money>0);
//
//    printf("%d年后,小甲鱼败光了所有家产,再次回到一贫如洗!",time);

//action 2
//    int i=1,k=0;
//    double re,sum=1;
//
//    while((re=fabs(1./i))>=1e-8){
//      if(k%2==0){
//            sum=sum-1./(i+2);
//      }else{
//            sum=sum+1./(i+2);
//      }
//      k++;
//      i+=2;
//
//    }
//    printf("PI的近似值为%.7f",sum*4);

//action 3 兔子的繁殖问题 (见台式机斐波那契数列示意图,1,1, 2,3,5,8,11...)
    int i,num;

    num=1,
    num=1;

    for(i=3;i<=24;i++){
      num=num+num;
//      printf("%d个月之后可以繁殖兔子%d对\n",i,num);
    }

    printf("两年之后可以繁殖兔子%d对",num);

紫陌 发表于 2018-4-26 10:48:30

ajikan 发表于 2018-5-5 22:08:35

先看看问答题答案

甲骨文特别快 发表于 2018-5-6 21:13:08

da
页: 12 13 14 15 16 17 18 19 20 21 [22] 23 24 25 26 27 28 29 30 31
查看完整版本: S1E16:拾遗 | 课后测试题及答案