鱼C论坛

 找回密码
 立即注册
楼主: 小甲鱼

[课后作业] S1E16:拾遗 | 课后测试题及答案

  [复制链接]
发表于 2022-9-15 15:36:13 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-16 14:57:48 | 显示全部楼层

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-16 17:00:00 From FishC Mobile | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-16 20:16:50 | 显示全部楼层
huifu
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-18 19:30:14 | 显示全部楼层
学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-19 15:44:49 | 显示全部楼层
.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-20 16:32:04 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-20 20:45:37 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-20 21:37:39 | 显示全部楼层
查看参考答案
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 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);
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 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);
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-20 23:31:04 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-21 15:43:27 | 显示全部楼层
11

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 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);
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 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);

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 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);
       
}
*/
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 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);
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 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);

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-25 18:07:35 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-9-25 22:46:54 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-7 10:22

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表