FFFa 发表于 2025-5-17 14:28:43

tyty

VCH 发表于 2025-5-19 13:36:06

S1E16拾遗
测试题
0.100次
1.0次因为i++先返回0直接退出循环
2.abc都是
3.14,5,9
4.z = x < 0 ? abs(x) : x
5.
A.
if (size > 12)
{
      cost = cost * 1.05;
      flag = 2;
      bill = cost * flag;
}
bill = cost * flag;
B.
if (ibex > 14)
{
      sheds = 3;
      help = 2 * sheds;
}
help = 2 * sheds;
C.
do
{
scanf("%d", &score);
if (score < 0)
    {
      break;
    }
count++;
}while(True);
printf("count = %d\n", count);

S1E16动动手
0.
#include <stdio.h>
#include <math.h>

int main(){
    float money_jiayu = 0;
    float money_heiye = 0;
   
    int year = 1;
    while (money_jiayu >= money_heiye)
    {
      money_jiayu = 10000;
      money_jiayu = money_jiayu * (1 + 0.1 * year);
      money_heiye = 10000;
      money_heiye = money_heiye * pow(1.05, year);

      year ++;
    }
    printf("%d年后,黑夜的投资额超过小甲鱼!\n",year - 1);
    printf("小甲鱼的投资额是:%.2f\n",money_jiayu);
    printf("黑夜的投资额是:%.2f\n",money_heiye);
    return 0;
}
S1E16动动手:
1.
#include <stdio.h>
#include <math.h>

int main(){
    float cunkuan = 4000000;
    int year = 0;
    do
    {
      cunkuan = cunkuan * (1 + 0.08);
      year ++;
      cunkuan -= 500000;
    } while (cunkuan > 0 );
    printf("%d年后败光!",year);
   
    return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
    double fenmu = 1;
    double a = pow(10,-8);
    double latest = fabs(a);
    double count = 0;
    int j = 1;
    double result;
    while (1 / fenmu >= latest)
    {
      count = count + j * (1 / fenmu);
      j = -j;
      fenmu = fenmu + 2;
    }
    result = count * 4;
    printf("π的值是:%.7f\n",result);
    printf("Hello");
    return 0;
}
S1E16动动手:
3.不会。我感觉这需要面向对象的编程处理起来会比较简单。

上天入地游西西 发表于 2025-5-21 16:49:10

1111111111111111111111111111111

思小海ovo 发表于 2025-5-21 16:56:22

1

水银炒鸡蛋 发表于 2025-5-23 23:45:14

10

11

a,b,c

14,5,9

#include <stdio.h>

int main()
{
       
        int x , z;
        printf("请输入一个数:");
        scanf("%d", &x);

        z = (x >= 0) ? x : -x;
        printf("绝对值x等于:%d\n" , z);
       
        return 0;       
}

baine 发表于 2025-6-7 17:23:02

1

kai_2025 发表于 2025-6-19 16:04:07

0619

D5000CODER 发表于 2025-6-24 17:11:02

测试题:
0.10个。
1.0个。
2.a,b,c。
3.a=14,c=9,b=5。
4.#include <stdio.h>

int main()
{
    int x,z;

    printf("请输入一个整数:\n");
    scanf("%d",&x);

    z = x > 0 ? x : -x;

    printf("求绝对值得:z = %d",z);
   
    return 0;
}
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>
#include <math.h>

int main()
{
    int count = 0;
    double i = 10000,j = 10000;
    double a = 10000,b = 10000;

    while (b <= a)
    {
      a =i + (1000*count);
      b = j * pow(1.05,count);
      count++;
    }

    printf("%d年后,黑夜的投资额超过小甲鱼!\n",count);
    printf("小甲鱼的投资额是:%d\n",a);
    printf("黑夜的投资额是:%d\n",b);
   
    return 0;
}
1.
#include <stdio.h>

int main()
{
    int year = 0;
    double money = 4000000;
    double this_year_start_money = 4000000;

    printf("初始资金:%.2f元\n",money);

    while (money >= 0)
    {
      year++;
      money = money - 500000;
      money = money * 1.08;

      printf("第%d年末,取出50万元后剩余%.2f元\n",year,money);
    }
   
    printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......\n",year);
   
    return 0;
}
2.
#include <stdio.h>
#include <math.h>

int main()
{
    double i = -3,pi,sum = 0;

    while (fabs(i)<100000000)
    {
      sum = sum + (1/i);
      if (i < 0)
      {
            i = fabs(i) + 2;
      }
      else
      {
            i = fabs(i) + 2;
            i = -i;
      }
      
    }
   
    pi = 4 * (1 + sum);
    printf("pi = %.8f\n",pi);
   
    return 0;
}
3.不会

火柴人618 发表于 2025-6-29 23:16:43

        鱼C有你更精彩^_^

简三十三 发表于 2025-6-30 15:39:10

1

maonine 发表于 2025-7-3 11:24:11

#include <stdio.h>

#define MONEY 10000

int main()
{
double a_total = MONEY, b_total = MONEY;
int count = 0;

do
{
a_total += MONEY * 0.1;
b_total += b_total * 0.05;
count++;
} while(a_total >= b_total);

printf("%d年后,黑夜的投资额超过小甲鱼!\n", count); //27年
printf("小甲鱼的投资额是:%.2f\n", a_total);
printf("黑夜的投资额是:%.2f\n", b_total);

return 0;
}
#include <stdio.h>
int main()
{
        double a=4000000;
        int i=0;
        while(a>=0)
        {
                a=a*1.08-500000;
                i++;
               
        }
       
        printf("%d年后,小甲鱼败光了所有财产!\n", i);
       

return 0;
}
#include <stdio.h>
#include <math.h>

int main()
{
      int sign = 1; // 表示符号
      double pi = 0.0, n = 1, term = 1.0; // n表示分母,term表示当前项的值

      while (fabs(term) >= 1e-8) // 1e-8表示10^(-8)
      {
                pi = pi + term;
                n = n + 2;
                sign = -sign;
                term = sign / n;
      }

      pi = pi * 4;
      printf("pi = %10.7f\n", pi);

      return 0;
}

动听c语言 发表于 2025-7-6 10:04:18

棒棒哒

有点像镜音连 发表于 2025-7-9 08:34:50

答案

乱世孤舟 发表于 2025-7-11 23:24:39

{:5_110:}

郭晓阳 发表于 2025-7-16 21:11:19

东谭井橙皮匠 发表于 2025-7-18 14:54:06

1

wjh302 发表于 2025-7-20 21:11:09

1

Merlyn丶W 发表于 2025-7-24 21:57:19

0. 10个
1. 9个
2. a b c
3. 5 5 9
4.
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.
for(;score>0;count++)
{
scanf("%d", &score);
}
printf("count = %d\n", count);

牧灵芸 发表于 2025-7-25 15:33:37

{:5_101:}

一只普通的吸管 发表于 2025-7-31 22:10:21

0. 100
1. 11
2. a=b=c
3. 13 4 9
4. z = x > 0 ? x : -x;
5. if (size > 12) {
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;

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

int score
while(1) {
scanf("%d", &score);
if (score < 0)
{
      break;
}
count++;
}
printf("count = %d\n", count);
页: 278 279 280 281 282 283 284 285 286 287 [288] 289
查看完整版本: S1E16:拾遗 | 课后测试题及答案