lqb 发表于 2019-4-9 22:05:49

看看

YiMingC 发表于 2019-4-10 17:24:20

0. 请问下边代码将打印多少个 'A'?l{XbOt2r
RA39"X6IE}v_H`:SuNr%#=^fCw.0
1.        #include <stdio.h>
2.       
3.        int main()
4.        {
5.                int i, j;
6.       
7.                for (i = 0; i != 10, j != 10; i++)
8.                {
9.                      for (j = 0; j < 10; j++)
10.                      {
11.                                putchar('A');
12.                      }
13.                }
14.       
15.                putchar('\n');
16.       
17.                return 0;
18.        }
答:10个

1. 请问下边代码会打印多少个 'B'?0L:?F
]d|ojcH'5iq^2}W=K>7<B8y;wDfkPn
1.        #include <stdio.h>
2.       
3.        int main()
4.        {
5.                int i = 0;
6.       
7.                while (i++)
8.                {
9.                      if (i > 10)
10.                      {
11.                                goto Label;
12.                      }
13.                      putchar('B');
14.                }
15.       
16.        Label:putchar('\n');
17.       
18.                return 0;
19.        }
答:九个。

2. 请写出表达式 a = b = c = 5 中的"l-value"?
答:5

3. 请问表达式 a = (b = 3, 4, c = b++ + 5, ++c + ++b); 执行后,整型变量 a、b、c 的值是?
答:
A=13
B=5
C=9

4. 请使用条件运算符求出变量 x 的绝对值,并存放到变量 z 中。
答:
X>0?x:-x;


5. C 语言其实在大部分情况下不使用 goto 语句也能做得很好,请尝试将下列代码段写成不带 goto 语句的版本。u6BwLkd
"6Oo|nq>a=He1w~+B%@ 'pc&5C
A. 版权属于:bbs.fishc.com
1.        if (size > 12)
2.        {
3.                goto a;
4.        }
5.        goto b;
6.        a:      cost = cost * 1.05;
7.                flag = 2;
8.        b:      bill = cost * flag;
复制代码

If(size>12)
{
        cost=cost*1.05;
}
Else
{
        bill = cost*flag;
}

B. 版权属于:bbs.fishc.com
1.        if (ibex > 14)
2.        {
3.                goto a;
4.        }
5.        sheds = 2;
6.        goto b;
7.        a:      sheds = 3;
8.        b:      help = 2 * sheds;
复制代码

If(ibex>14)
{
        sheds=3;
}
Else
{
Sheds-2;
Help=2*sheds;
}

C.版权属于:bbs.fishc.com
1.        readin: scanf("%d", &score);
2.        if (score < 0)
3.        {
4.                goto stage2;
5.        }
6.        count++;
7.        goto    readin;
8.        stage2: printf("count = %d\n", count);



for(score=scanf(“%d”,&score);score>=0;count++)
{
score = scanf(“%d”,&score);
}
Printf(“count = %d\n”,count);


#include <stdio.h>
main()
{
      float fish=10000.00,heiye=10000.0;
      int year=0;
      for (;fish>=heiye;year++)
      {
                fish += 1000;
                heiye *=1.05;
      }
      printf("%d年后,黑夜的投资额超过小甲鱼!\n",year);
      printf("小甲鱼的投资额是:%.2f\n",fish);
      printf("黑夜的投资额是:%.2f\n",heiye);

}


#include <stdio.h>
main()
{
      int year=0;
      float money=400.00;
      for (;;year++)
      {
                money -= 50;
                if(money<0)
                {
                        year++;
                        break;
                }
                else
                {
                        money *=1.08;
                }
      }
      printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......\n",year);
}

#include <stdio.h>
main()
{
      long int sum,adult=1,child=0,new0=0,new1=0,newj=0;
      int time;
      for (time=0;time<=24;time++)
      {
                child=child+adult;
                new0 = new1;
                new2 = newj;
                newj = adult;
                adult +=new0;
      }
      sum = child+adult;
      printf("一共有%ld对兔子!\n",sum);

}
~                        

Boat-libery 发表于 2019-4-10 19:39:45

答案

bizhiliang 发表于 2019-4-10 19:40:34

查看答案

微风中的碎片 发表于 2019-4-10 22:04:01

ok

郭恩峰 发表于 2019-4-11 10:54:26

欧克

HUMMER军 发表于 2019-4-12 18:18:01

0.100次
1.0次
2.abc
3.16 6 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;
}
sheds = 2;
help = 2 * sheds;
C.
if (score < 0)
{
printf("count = %d\n", count);
}
count++;
scanf("%d", &score);

HUMMER军 发表于 2019-4-12 18:58:31

动动手0
#include <stdio.h>
#include <math.h>
int main(void) {
double money=10000,n1=0.1,n2=0.05,sum1,sum2;
for(int i=1;i<100;i++){
    sum1=money+(money*n1*i);
    sum2=money*pow((1+n2),i);
    if(sum2>sum1){
      printf("%d年后,黑夜投资额超过小甲鱼\n",i);
      break;
    }
}
printf("小甲鱼的投资额是:%.2lf\n",sum1);
printf("黑夜的投资额是:%.2lf\n",sum2);
return 0;
}

动动手1
#include <stdio.h>
#include <math.h>
int main(void) {
int sum=400,year;
double r=0.08;
for(year=1;year<100;year++){
    sum=(sum-50)*(1+0.08);
    if (sum<0){
      printf("%d年后,败光!\n",year);
      break;
    }
}
return 0;
}

1133302059 发表于 2019-4-13 21:17:51

兔子好难{:10_247:}

小圣呀 发表于 2019-4-14 09:29:01

0-9 10个

i++ 是0 不进入循环啊。。


a, a=b, a=b=c

b = 5 , c = 9
a = 9 + 5 = 14

z = x > 0 ? x:-x

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);

Leslie.C 发表于 2019-4-14 13:53:38

0.10个A
1.11
2.
3.8,3,3
4.
5.

BIT_烟囱 发表于 2019-4-14 17:19:36

1

Ben佘 发表于 2019-4-14 20:26:25

: )

19978349690 发表于 2019-4-15 12:43:08

查看参考答案

qq7273399499 发表于 2019-4-15 13:07:24

看看

15579618832 发表于 2019-4-15 19:26:12

0. 10
1. 10
2.a,b, c
3. a = 12, b = 4, c = 8
4. z = |x|
5. if (size > 12)               
{
         cost = cost * 1.05;
}
else if(flag = 2)
{
   bill = cost * flag;
}
2.
if (ibex > 14)
{
      sheds = 3;
}
else if(sheds = 2;)
}
help = 2 * sheds;
}
3.
readin:scanf("%d", &score);
while(readin : scanf("%d", &scaore) == 0)
{
if(score < 0)
{
printf("count = %d\n", count);
}
}
   

bakuyi 发表于 2019-4-16 10:24:17

{:10_266:}

echohah 发表于 2019-4-16 11:13:42

        无条件支持楼主!

ajiemmd 发表于 2019-4-17 18:06:15

111

Robert丶 发表于 2019-4-17 23:05:24

1
页: 35 36 37 38 39 40 41 42 43 44 [45] 46 47 48 49 50 51 52 53 54
查看完整版本: S1E16:拾遗 | 课后测试题及答案