徹羽 发表于 2022-9-15 15:36:13

1

Abadnoned元 发表于 2022-9-16 14:57:48


1149380706 发表于 2022-9-16 17:00:00

1

折折星 发表于 2022-9-16 20:16:50

huifu

spikewin 发表于 2022-9-18 19:30:14

学习

池上桜 发表于 2022-9-19 15:44:49

.

PForeste 发表于 2022-9-20 16:32:04

{:5_90:}

py2625 发表于 2022-9-20 20:45:37

{:9_241:}

菜菜c 发表于 2022-9-20 21:37:39

查看参考答案

thrich3 发表于 2022-9-20 22:18:27

1 10
2 11
3 a,b,c
4 14,5,9
5 a = (a > 0 ? : a = -a)
6
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(score > 0)
        {
                scanf("%d",&score)
                count++;
        }
       
        printf("count = %d\n",count);

Boran777 发表于 2022-9-20 22:39:36

0. 10
1. 10
2. a, b, c
3. a = 14; b = 5; c = 9
4. z = (x > 0 ? x : 0 - 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)
                break;
      count++;
}
printf("count = %d\n", count);

assic 发表于 2022-9-20 23:31:04

1

力大无穷 发表于 2022-9-21 15:43:27

11

正天圣人 发表于 2022-9-21 20:38:07

0.10次
1.0次
2.a
3.a=14
b=5,
c=9
4.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>
int main()
{
        float a=10000,b,c;
        int i=0;
        for(b=a,c=a;b>=c;)
        {
                b=b+a*0.1;
                c=c+c*0.05;
                if(b>=c)
                {
                        i++;
                }
        }
        printf("%d年后,黑夜的投资额超过小甲鱼。\n",i);
        printf("小甲鱼的投资额是%.2f,黑夜的投资额是%.2f。",b,c);
}

1.#include<stdio.h>
int main()
{
        float a=400,b=50;
        int c=0;
        while(a>0)
        {
                a=a*(1+0.08)-50;
                c++;
        }
        printf("%d年后,小甲鱼败光家产,再次回到一贫如洗的状态。",c-2);
}

2.#include<stdio.h>
#include<math.h>
int main()
{
        double a,b,c,d,e;
        for(a=1,b=1,c=1,d=-1,e=0;(d>pow(10,(-8))*(-c)&&c<0)||(d<pow(10,(-8))*(-c)&&c>0);)
        {
                d=a/b*c;
                b=b+2;
                c=c*(-1);
                if((d>pow(10,(-8))*(-c)&&c<0)||(d<pow(10,(-8)*(-c))&&c>0))
                e=e+d;
        }
        printf("%.7f\n",e);
}

3.#include<stdio.h>
int main()
{
        int a,b;
        for(a=1,b=1;b<12*2;b++)
        {
                a=a*2;
        }
        printf("一共%d个兔子",a);
}

Tycoonz 发表于 2022-9-22 10:24:54

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

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

幻狠美 发表于 2022-9-22 16:58:22

#include <stdio.h>


/*测试题 0
10个'A',j循环10次后最外层for循环判断语句判断j!=10为假直接退出循环

测试题 1
10个'B',while循环先判断i=0再i++,此时再循环语句里i=1,
所以if语句判断i是从1~10都是假(10次),i=11时才为真跳出循环

测试题 2
abc都是吧,等号赋值运算符从右向左

测试题 3
a=15;b=5;c=10; 逗号运算符会用最右侧的值赋值

测试题 4
z=x>0?x:(-x); 表达式1?表达式2:表达式3;表达式为真则执行表达式2,假则执行表达式3

测试题 5
A:
if (size > 12)
{
      cost = cost * 1.05;
      flag =2;
      bill = cost * flag;
}
else{
bill = cost * flag;
}


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

C:
for(scanf("%d",&score);score>=0;scanf("%d",&score)){
        count++;
}
printf("count = %d\n", count);

动动手 0
int main()
{
        int money=10000,year;
        double i=10000,j=10000;
       
        for(year=0;j<=i;year++){
                i+=(money*0.1);
                j*=1.05;       
        }
        printf("%d年后,黑夜的投资额超过小甲鱼!\n\
小甲鱼的投资额是:%.2f\n\
黑夜的投资额是:%.2f",year,i,j);

        return 0;
}

动动手 1
int main(){
        double i=4.0e6,j=5.0e5;
        int year;
       
        for(year=0;i>0;year++){
                i-=j;
                i*=1.08;
        }
        printf("%d年之后,小甲鱼败光了所有家产,再次回到一贫如洗……",year);       
}

动动手 2
int main(){
        double pi=0,i;
        double j;
        for(j=1,i=-1;j<1e8;j+=2){
                i=-i;
                pi+=i*(1/j);       
        }
        pi*=4;
        printf("小数点后7位的pi为%.7f",pi);
}

动动手 3

int main(){
        int i=1,j=1,amount,month;
        for(month=3;month<=6;month++){
                amount=i+j;
                j=i;
                i=amount;
        }
        amount--;
        printf("两年后可以繁殖出%d对兔子(不包括最开始一对兔子)",amount);
       
}
*/

jianxing2077 发表于 2022-9-23 14:43:17

11
0
a,b,c
14 5 9
x<0?z=-x:z=x;

A if(size>12){cost = cost*1.05; flag = 2;} bill = cost*flag;
B if(ibex>14){sheds = 3;}else sheds=2; help = sheds *2;
C do{scanf("%d",&score); if (score<0){printf("count = %d\n",count); break;} count++;}

#include <stdio.h>

int main()
{
      float a=10000;
      float b=10000;
      int i=00;
               
                while (a >= b){
                        a += 1000;
                        b *= 1.05;
                        i++;
                }
                printf("%d年后,黑夜的投资额超过小甲鱼!\n小甲鱼的投资额是:%f\n黑夜的投资额是:%f",i,a,b);
      return 0;
}

#include <stdio.h>

int main()
{
        float a=400;
        int i = 0;
        do
        {
                a -= 50;
                a *= 1.08;
                i++;
        }
        while (a>0);
        printf("%d",i);
}



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

int main()
{
        int i = 2;
        for (int n = 1;n <= 24;n++)
                i = pow(2,n);
       
        printf("%d",i);
}

晓晓混分日记 发表于 2022-9-25 07:06:37

0. 10个A

1. 10个B

2. a, b, c

3. a = 18, b =4, c = 10

4. x > 0? z = x : z = 0 - x

5.
A.
if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
      break;
}
bill = cost * flag;

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

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

y147258 发表于 2022-9-25 18:07:35

1

来都来了777 发表于 2022-9-25 22:46:54

页: 229 230 231 232 233 234 235 236 237 238 [239] 240 241 242 243 244 245 246 247 248
查看完整版本: S1E16:拾遗 | 课后测试题及答案