鱼C论坛

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

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

  [复制链接]
发表于 2021-10-18 20:24:31 | 显示全部楼层
‘’‘
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-18 21:16:59 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-18 22:48:17 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-19 03:07:54 | 显示全部楼层
0. 10

1. 10

2. c, b, a

3.

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

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

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


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

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

使用道具 举报

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

使用道具 举报

发表于 2021-10-19 10:54:30 | 显示全部楼层
0.10
1.0
2.a = b;
b = c;
c= 5;
3.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-19 17:16:41 | 显示全部楼层
0: 10
1: 10
2:

a=5
b=5
c=5

3:

a=4
b=3
c=8

4:

5:

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

B:

if (ibex > 14)
{
        sheds = 3;
        break;
}

      sheds = 3;
      help = 2 * sheds;

C:

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

动动手:
0:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    double x=10000, y=10000,c=0;
   
    for (int i = 1; i < 1000; i++)
    {
        c = 10000 * 0.1;
        x = x + c;
        y = y + y * 0.05;

        if (y > x)
        {
            printf("%d年后y超越x\n",i);
            printf("x=%f\ny=%f",x,y);
            break;
        }

    }
   
    return 0;
}

1:

    double x=4000000, y=500000,c=0;
   
    for (int i = 1; i < 1000; i++)
    {
        x = x - y;
        x = x * 0.08 + x;

        if (x<=0)
        {
            printf("%d年后破产",i);
            break;
        }

    }

2:

    double PI=(2/3), x=3,y=0;
   
    for (int n = 1; n < 10000; n++)
    {
        if (n > 1)
        {
            x = x + 2;
            if (n % 2 != 0)
            {
                PI = PI - (1 / x);
            }
            if (n % 2 == 0)
            {
                PI = PI + (1 / x);
            }
        }   
        printf("%.7f\n",PI);
    }
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-19 17:40:30 | 显示全部楼层
#include<stdio.h>

int main()
{
    float x, z;
   
    printf("请输入数字:");
    scanf("%f", &x);
   
    if(x<0)
    {
      z = -x;
    }
    else
    {
      z = x;
    }

    printf("他的绝对值为%.2f", z);
    return 0;
}if(size>12)
{
  cost *= 1.05;
  flag = 2;
}
bill = cost * flag;if(ibex>14)
{
  sheds = 3;
}
else
{
  sheds = 2;
}
help = 2 * sheds;while(a = scanf("%d", &score))
{
      if(score<0)
      {
        printf("count = %d", count);
        break;
      }
      else
      {
        count++;
      }
}#include<stdio.h>
#include<math.h>

int main()
{
    int year = 1;
    float xjy, hy;
   
    for(year = 1;year>=1;year++)
    {
       xjy = 10000 * (1 + 0.1 * year);
       hy = 10000 * pow(1 + 0.05,year);
       if(hy>xjy)
       {
         printf("%d年后,黑夜的投资额大于小甲鱼!\n", year);
         printf("小甲鱼的投资额是:%.2f\n", xjy);
         printf("黑夜的投资额是:%.2f", hy);
         break;
       }
   
    }
    return 0;
}#include<stdio.h>
#include<math.h>

int main()
{
    int year;
    double a;

    for(year = 1; year>=1; year++)
    {
        a = 4000000 * pow(1.08,year)-500000 * (pow(1.08,year) * (1 - pow(1/1.08,year - 1)))/(1 - (1/1.08));
        if(a<=0)
        {
            printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗...", year);
            break;
        }
    }
    return 0;
}#include<stdio.h>
#include<math.h>

int main()
{
    double a = 0;
    int n;
    for(n = 0;n>=0;n++)
    {
       a = (pow(-1,n))*1/(1 + 2*n) + a;
       if(1/(1 + 2*n)<pow(10,-8))
       {
         printf("%.7f", 4*a);
         break;
       }
   
    }
   
    return 0;
}#include<stdio.h>

int main()
{
    int a = 2, b = 1;
    for(b = 1;b<=24;b++)
    {
        if(b<=4)
        {
          a = b * 2;
        }
        else
        {
          a = a + (b - 3)*2;
        }
   
    }
    printf("两年后一共%d只兔子", a);
    return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-19 18:52:17 | 显示全部楼层
10
10
a

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

使用道具 举报

发表于 2021-10-19 20:49:02 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-19 21:25:50 | 显示全部楼层
..
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-19 23:27:11 | 显示全部楼层
0.100
1.10
2.c,b,a
3.16 6 11
4. z = x >= 0 ? x : -x;
5.if (size > 12)
{
        cost = cost * 1.05;
        flag = 2;
}
bill = cost * flag;

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

while (readin)
{
    if (score < 0)
    {
            printf("count = %d\n", count);
            break;
    }
count++;
readin = scanf("%d", &score);
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-20 11:49:05 | 显示全部楼层
_(:з」∠)_
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

使用道具 举报

发表于 2021-10-20 15:12:17 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-20 18:57:14 | 显示全部楼层
.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-20 19:23:07 | 显示全部楼层
31


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

使用道具 举报

发表于 2021-10-20 20:15:45 | 显示全部楼层
今天也是努力的一天
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-10-21 12:27:18 | 显示全部楼层
0.
10个
1.
0个
2.
a, b, c
3.
a = 14; b = 5; c = 9;
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.

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


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

使用道具 举报

发表于 2021-10-21 12:35:38 | 显示全部楼层
0.
10个
1.
0个
2.
a, b, c
3.
a = 14; b = 5; c = 9;
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.

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



动动手
0.
#include <stdio.h>
#define PRINCIPAL 10000

int main()
{
        float principal1 = PRINCIPAL, principal2 = PRINCIPAL;
        int year;
        
        for (year = 0; principal1 >= principal2; year++)
        {
                principal1 += PRINCIPAL * 0.1;
                principal2 *= 1 + 0.05; 
        }
        
        printf("%d年后 , 黑夜的投资额超过小甲鱼!\n小甲鱼的投资额是 : %.2f\n黑夜的投资额是 : %.2f\n", year, principal1, principal2);
        
        return 0;
}


1.
#include <stdio.h>

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

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

int main()
{
        double sum = 0, num = 1.0;
        
        do 
        {
                sum += num;
        }while (fabs(num = -1.0/(num < 0 ? 1.0/num - 2 : 1.0/num + 2)) >= pow(10, -8));

        printf("%.7f", 4 * sum);
        
        return 0;
}


3.
#include <stdio.h>

int main()
{
        int a = 1, b = 1, temp;
        
        for (int i = 2; i < 24; i++)
        {
                temp = b;
                b = a + b;
                a = temp;
        }
        
        printf("两年后可以繁殖%d次\n", b);
        
        return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-10-7 00:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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