layicode 发表于 2022-11-27 17:47:26

1

15974432466 发表于 2022-11-28 13:03:55

鱼C有你更精彩^_^

日骑士的龙 发表于 2022-11-28 17:33:32

0.110
1.11
2.
3.c9a14b5
4.

Aixer 发表于 2022-11-28 21:03:25

thank

zcca 发表于 2022-11-29 14:39:12

0. 请问下边代码将打印多少个 'A'

#include <stdio.h>

int main()
{
      int i, j;

      for (i = 0; i != 10, j != 10; i++)
      {
                for (j = 0; j < 10; j++)
                {
                        putchar('A');
                }
      }

      putchar('\n');

      return 0;
}

10个

1. 请问下边代码会打印多少个 'B'?

#include <stdio.h>

int main()
{
      int i = 0;

      while (i++)
      {
                if (i > 10)
                {
                        goto Label;
                }
                putchar('B');
      }

Label:putchar('\n');

      return 0;
}

11个

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

a=b
b=c
c=5

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

a=14
b=5
c=9

4. 请使用条件运算符求出变量 x 的绝对值,并存放到变量 z 中。
x = x<0 ? fabs(x) : x;
      
                x = z;


5. C 语言其实在大部分情况下不使用 goto 语句也能做得很好,请尝试将下列代码段写成不带 goto 语句的版本

1.
if (size > 12)
{
      goto a;
}
goto b;
a:      cost = cost * 1.05;
      flag = 2;
b:      bill = cost * flag;

改为
        int size,cost,bill,flag;               
        if (size > 12)
        {
                       a:cost = cost * 1.05;
                      flag = 2;
        }
        else
        {
                b:bill = cost * flag;
        }

2.
if (ibex > 14)
{
      goto a;
}
sheds = 2;
goto b;
a:      sheds = 3;
b:      help = 2 * sheds;

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

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

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

15767087377 发表于 2022-11-30 16:14:36

1

huangkai7722 发表于 2022-12-1 14:48:23

朕想知道

诗羽monyu 发表于 2022-12-2 16:44:43

继续学习上大分问答题答案:



动动手答案:


月下饮酒影独醉 发表于 2022-12-2 21:07:15

问答题答案:
0. 100
1. 10
2. a, b, c
3. 14
4.
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.
scanf("%d", &score);
        if(score < 0){
                printf("count %d\n", count);
        }else {
                count++;
        }
动动手答案:
0.
#include <stdio.h>
#include <math.h>
int main(){
        int corpus = 10000;
        // money1 小甲鱼投资额,money2 黑夜投资额
        double money1 = 0, money2 = 0;
        printf("%.2f %.2f\n", money1, money2);
        int count = 1;
        while (1){
                money1 = (count * 0.1 * corpus) + corpus;
                money2 = corpus * pow(1 + 0.05, count);       
                if(money2 > money1){
                        break;
                }
                count++;
        }
        printf("%d年后,黑夜的投资额超过小甲鱼!\n", count);
        printf("小甲鱼的投资额是:%.2f\n", money1);
        printf("黑夜的投资额是:%.2f\n", money2);
        return 0;

}
1.
#include <stdio.h>

int main(){
        int count = 0;
        double money = 4000000, temp;
       
               while (money >= 0) {
                count++;
                temp = money - 500000;
                money = temp + temp * 0.08;
        }       

        printf("%d年之后,小甲鱼败光了所有的家产,再次回到一瓶如洗......\n", count);
        return 0;
}

2.
3.
#include <stdio.h>

int main(){
        int x = 1, y = 1, temp;
        int i;
        for (i = 2; i <= 24; i++){
                temp = x + y;
                x = y;
                y = temp;
        }
        printf("兔子在两年后能繁殖%d对兔子\n", y);
        return 0;
       
}

C160 发表于 2022-12-3 15:38:46

问答题答案:

kk


动动手答案:


阿俊编程梦 发表于 2022-12-3 20:45:07

问答题答案:
1


动动手答案:


梵倪倪 发表于 2022-12-5 08:26:51

问答题答案:



动动手答案:


zy990106 发表于 2022-12-5 11:22:25

问答题答案:复



动动手答案:复


yun.c 发表于 2022-12-5 12:55:58

问答题答案:



动动手答案:


liuyixun1231 发表于 2022-12-7 16:22:27

1问答题答案:



动动手答案:


2164930278 发表于 2022-12-7 20:53:58

测试题答案:
0.10        1.10        2.c==5&&a==c&&b==c
3.a=14.8b=5.4c=9.4
4.z=x>0?x:-x;
5.A
if(size>12)
{
        cost=cost*1.05;
        flag=2;
        bill=cost*flag;
}
bill=cost*flag;

B
if(ibex>14)
{
        sheds=s;
        help=2*sheds;
}
sheds=2;
help=2*sheds;
C.
do
{
        scanf("%d",&score);
        if(score<o)
        {
                break;
        }
        count++;
}while(1);
printf("count:%d\n",count);

动动手答案:

0.
double inv1,inv2;
int year=0;
inv1=inv2=10000;
do
{
        inv1+=10000*0.1;
        inv2+=inv2*0.05;
        year++;
}while(inv1<inv2);
printf("%d年后,黑夜的投资额超过小甲鱼!\n");
printf("小甲鱼的投资额是%.2f\n",inv1);
printf("黑夜的投资额是%.2f\n",inv2);


1.
long float der=400E4;
int year=0;
while(der>0)
{
        der+=der*0.08;
        der-=50E4;
        year++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……",year);


2.
double sum=0.0,temp;
int m=1,n=1,sign=1;
temp=(double)m/n;
while(fabs(temp)>=1E-8)
{
        sum+=temp;
        n+=2;
        sign=-sign;
        temp=(double)m/n*sign;
}
printf("PI=%.7f\n",sum*4.0);


3.
int sum=2,month=24;
for(;month>0;month-=2)
{
        sum*=2;
}
printf("两年之后可以繁殖%d只兔子\n",sum);

顾然Gu_Ran 发表于 2022-12-7 21:31:16

圆周率
问答题答案:



动动手答案:


WTL2002hh 发表于 2022-12-8 00:04:00

1问答题答案:



动动手答案:


维德 发表于 2022-12-10 14:25:04

11111111111111111问答题答案:



动动手答案:


噎死青春 发表于 2022-12-10 16:16:42

问答题答案:



动动手答案:


页: 238 239 240 241 242 243 244 245 246 247 [248] 249 250 251 252 253 254 255 256 257
查看完整版本: S1E16:拾遗 | 课后测试题及答案