MN_Guan 发表于 2020-3-7 22:05:17

0:10
1:运行前感觉是10次,运行后是0次,因为i++执行时i=0,不进入while循环
2:a、b、c
3:a=15   b=5c=10
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:
do
{       
        scanf("%d",&score);
        count++;
}
while(!(score<0));
printf("count = %d\n",count);
--------------------------


动动手:
0:
#include<stdio.h>
int main()
{
      int i=0;
      float FishC=10000;
      float night=10000;

      while(night<=FishC)
      {
                FishC+=10000*0.1;
                night+=night*0.05;
                i++;
      }
      printf("%d年后,黑夜的投资额超过小甲鱼!\n",i);
      printf("小甲鱼的投资额是%.2f\n",FishC);
      printf("黑夜的投资额是%.2f\n",night);
      return 0;
}



1:
#include<stdio.h>
int main()
{
      float total=400;
      int i=1;
      while((total-=50)>0)
      {
                total+=total*0.08;
                i++;
      }
      printf("%d年之后,小甲鱼败光了了所有的家产,再次回到一贫如洗......\n",i);
      return 0;
}


2:

判断条件降了一阶,运行时间太长了,这是1e-7的结果:3.1415966
#include<stdio.h>
#include<math.h>
int main()
{
//      float numerator=1;//分子
      float approximate_PI=0;//近似值
      int i=0;
      float denominator=1;//分母
      float limit=pow(10,-7);
      float fraction;//分数
      while((fraction=1/denominator)>=limit)
      {
                approximate_PI+=pow(-1,i++)*fraction;
                denominator+=2;
                printf("%.9f %d\n",fraction,i);
      }
      printf("PI的近似值为:%.7f\n",4*approximate_PI);
      return 0;
}


3:
//the answer is 75025


#include<stdio.h>
int main()
{
      int year0=1,year1=0,year2=0;
      for(int i=1;i<=24;i++)
      {
                year2+=year1;
                year1=year0;
                year0=year2;
      }
      printf("两年之后可以繁殖%d对兔子。\n",year0+year1+year2);
      return 0;
}

千秋寒夏 发表于 2020-3-7 23:18:20

浮点数

1394116864 发表于 2020-3-8 09:56:14

123

瞌睡小子 发表于 2020-3-8 10:43:42

拾遗

1106824646 发表于 2020-3-8 13:32:52

sadfgh

啊川 发表于 2020-3-8 15:01:27

0.

huanghuiyv 发表于 2020-3-8 15:33:29

无条件支持楼主!

yuanguohua 发表于 2020-3-8 17:00:12

1

大明天子 发表于 2020-3-8 17:12:29

割白菜喂猪 发表于 2017-1-5 23:13
地方

金咕咕 发表于 2020-3-9 12:47:53

瞅一下

我来学习de 发表于 2020-3-9 15:42:12

#include<stdio.h>

int main()
{
        int x,h,n,temp;
        int j;

       
                while(x>h)
                {
                        for(n=1;;n++)
                        {
                                temp=10000*0.1*n;
                                x=temp+10000;
                                for(j=1;j<n;j++)
                                {
                                        if(j==1)
                                        {
                                                h=(1+0.05)*10000;
                                        }
                                        else
                                        {
                                                h=(1+0.05)*h;
                                        }
                                }
                        }
                }
                printf("%d后,黑的资产超过小",n);
                printf("小的资产是%d\n黑的资产是%d",x,h);
                return 0;
}
#include<stdio.h>

int main()
{
        int n=1;
        int money=400;

       

                        while(money)
                        {
                               
                                if(n==1)
                                {
                                        money=400*0.08;
                                }
                                else
                                {
                                        money=money*0.08;
                                }
                                money-=50;
                                n++;
                        }

       
       
        printf("%d后,资产用光",n+1);
        return 0;
}

humanR 发表于 2020-3-9 17:56:46

1

dhzj159 发表于 2020-3-9 18:44:17

ss's

無用。 发表于 2020-3-9 20:40:45

我来检查答案了{:5_109:}

jiangyifei 发表于 2020-3-9 22:48:17

测试题答案:
0.10个
1.11个
2.a,b,c
3.a=14,b=5,c=9
4.
#include <stdio.h>
int main()
{
        float x;
        floata z;
        printf("请输入一个数:");
        scanf("%f",&x);
       
        z=x>0 ? x:x*(-1);
        printf("%f的绝对值是:%f\n",x,z);
    return 0;
}
5.
A.if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
}
bill = cost * flag;
B.if (ibex > 14)
{
      sheds = 3;
}
sheds = 2;
help = 2 * sheds;
C.readin: scanf("%d", &score);
if (score < 0)
{
       printf("count = %d\n", count);
}
count++;
动动手答案:
0.

suqiang357 发表于 2020-3-10 00:01:07

1

三台子刘德华 发表于 2020-3-10 15:02:00

滴滴答滴答

Wenty 发表于 2020-3-10 16:16:00

{:10_291:}

幸运巴别塔 发表于 2020-3-10 17:02:08

00

lh1592788511 发表于 2020-3-10 17:41:48

ljk
页: 81 82 83 84 85 86 87 88 89 90 [91] 92 93 94 95 96 97 98 99 100
查看完整版本: S1E16:拾遗 | 课后测试题及答案