林小尖 发表于 2021-9-27 22:06:02

redHmian 发表于 2021-9-27 22:40:19

{:5_109:}

Lauren- 发表于 2021-9-27 23:25:40

.

zhuangzitao 发表于 2021-9-28 11:19:56

#include <stdio.h>

int main(void)
{
        int year;
        float xiaojiayu = 10000.0f, heiye = 10000.0f;
       
        for (year = 1; heiye <= xiaojiayu; year++) {
                xiaojiayu += 10000 * 0.1;
                heiye *= 1.05;
        }
        printf("%d年后,黑夜的投资额超过小甲鱼!\n", year);
        printf("小甲鱼的投资额是: %.2f\n", xiaojiayu);
        printf("黑夜的投资额是: %.2f\n", heiye);
       
        return 0;
}

#include <stdio.h>

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

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

int main(void)
{
        double sum = 0.0;
        int i = 1;
        int temp = pow(10, 8);
        int count = 1;
       
        while ( fabs(i) <= temp) {
                if(count % 2 == 0)
                        i = -i;
                sum += 1.0 / i;
                i = fabs(i) + 2;
                count++;
        }
        printf("π的值为:%.7f", sum * 4);
       
        return 0;
}

#include <stdio.h>

int main(void)
{
        int sum = {1, 1}, i;
       
        for(i = 3; i < 24; i++) {
                sum = sum + sum;
                printf("现在有%d对兔子。\n", sum);
        }       
        printf("两年之后可以繁殖%d对兔子。\n", sum);
       
       
        return 0;
}

冲啊yongyong 发表于 2021-9-28 16:18:06

1

冲啊yongyong 发表于 2021-9-28 16:18:43

呃呃呃

944789838 发表于 2021-9-28 19:08:40

朕想知道

gxd666 发表于 2021-9-29 09:33:04

1

xydrain 发表于 2021-9-29 15:09:50

1

gxd666 发表于 2021-9-29 15:26:54

1

豆芽菜丶 发表于 2021-9-29 18:22:15

0、10
1、0
2、a.b.c
3、a=14,b=5,c=9
4、
#include <stdio.h>

int main()
{
    int x=-5, z;
    z = x < 0 ? -x : x;
    printf("%d",z);
    return 0;
}
5、
#include <stdio.h>

int main()
{
    int size, cost, bill, flag;

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

    return 0;
}
B、
if (ibex > 14)
      sheds = 3;
    else
      sheds = 2;

    help = 2 * sheds;
C、
do{
      scanf("%d", &score);
      count++;
    } while (score > 0);
    printf("count = %d\n", count-1);
动动手
0、
int years = 0;
    float count1 = 10000, count2 = 10000;
    do
    {
      years++;
      count1 += 1000 * years;
      count2 += count2 * 0.05;
      
    } while(count2<count1);
    printf("%d年后,黑夜的投资额超过了小甲鱼!\n", years);
    printf("小甲鱼的投资额是:%0.2f\n", count1);
    printf("黑夜的投资额是%0.2f\n", count2);
   
    return 0;
1、
    int years = 0;
    float count = 4000000;
    do
    {
      years++;
      count -= 500000;
      count += count*0.08;
    } while(count>0);
    printf("%d年后,小甲鱼败光了所以的家产,再次回到一贫如洗......\n", years);

    return 0;
2、
double i = 1, count = 0, pi;

    while (fabs(1 / i) > pow(10, -8))
    {
      count += 1 / i;
      i = -i;
      if (i < 0)
            i -= 2;
      else
            i += 2;
    }
    pi = count * 4;
    printf("%lf", pi);
3、

LeaflLit 发表于 2021-10-1 15:39:12

0.100
1.9
2.
3.a=14,b=4,c=8
4.z=(int)sqrt(double x*x)
5.

梦回汉唐 发表于 2021-10-1 17:38:59

验证代码

软大头 发表于 2021-10-2 15:28:34

asdasdasdasd

muoushi 发表于 2021-10-2 21:21:59

1

一只学C的萌新 发表于 2021-10-3 10:44:55

我是越来越搞不懂for语句了

putuo3 发表于 2021-10-3 13:55:11

46368

yccccccy 发表于 2021-10-3 15:21:52

1

东方笑 发表于 2021-10-3 16:16:08

1

Guillaume 发表于 2021-10-4 10:53:57

0
页: 182 183 184 185 186 187 188 189 190 191 [192] 193 194 195 196 197 198 199 200 201
查看完整版本: S1E16:拾遗 | 课后测试题及答案