KXHH 发表于 2021-10-18 20:24:31

‘’‘

犯点小错误 发表于 2021-10-18 21:16:59

仟渝 发表于 2021-10-18 22:48:17

1

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

1501672283 发表于 2021-10-19 10:00:06

fast1314 发表于 2021-10-19 10:54:30

0.10
1.0
2.a = b;
b = c;
c= 5;
3.

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

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

屋子很大 发表于 2021-10-19 18:52:17

10
10
a

lrw 发表于 2021-10-19 20:49:02

1

林江楠 发表于 2021-10-19 21:25:50

..

飞花落尽 发表于 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);

dabo 发表于 2021-10-20 11:49:05

_(:з」∠)_

2213216806 发表于 2021-10-20 14:50:04

1

炫U炫 发表于 2021-10-20 15:12:17

{:5_102:}

mmoli 发表于 2021-10-20 18:57:14

.

Ang_Ti 发表于 2021-10-20 19:23:07

31


AdiosSpike 发表于 2021-10-20 20:15:45

今天也是努力的一天

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


昵称加载错误 发表于 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;
}
页: 186 187 188 189 190 191 192 193 194 195 [196] 197 198 199 200 201 202 203 204 205
查看完整版本: S1E16:拾遗 | 课后测试题及答案