源浩cc 发表于 2024-3-24 10:40:11

答案

源浩cc 发表于 2024-3-24 10:40:46

答案

Kianamary 发表于 2024-3-25 14:24:09

answer

TTTTL 发表于 2024-3-25 20:42:36

0.10
1.0
2.a,b,c是l-value
3.a= 14, b=5, c=9
4.if(x > 0)
{
    z = x;
}
else
{
    z = -x;
}
5.将a,b分别代入goto a,b中

Marched 发表于 2024-3-26 22:08:35

查看参考答案

一大堆乱码 发表于 2024-3-29 09:20:54

+1

栀酒 发表于 2024-3-29 16:13:57

10
0

16
z = x > 0 ?x : -x

white_h 发表于 2024-3-29 22:06:43

0.10个'A'
1.0个'B'
2.a,b,c
3.
14 5 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;
}
sheds = 2;
help = 2 * sheds;

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

0.
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
        int i = 1;
        float xjy, hy;
        xjy = hy = 10000;
        xjy += 0.1 * xjy;
        hy += 0.05 * hy;
        while (xjy > hy)
        {
                i++;
                xjy += 1000;
                hy += 0.05 * hy;
        }
        printf("%d年后,黑夜的投资额超过小甲鱼!\n",i);
        printf("小甲鱼的投资额是:%.2f\n", xjy);
        printf("黑夜的投资额是:%.2f\n", hy);
        return 0;
}

1.
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
        int i=1;
        float money;
        money = (400 - 50) * (1 + 0.08);
        while (money >= 0)
        {
                i++;
                money = (money - 50) * (1 + 0.08);
        }
        printf("%d年后,小甲鱼败光所有家产,再次回到一贫如洗......", i);
        return 0;
}

2.
#define _CRT_SECURE_NOO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
        double pai,tmp;
        int i, j;
        i = j = 1;
        tmp = 1 / i;
        pai = tmp;
        while (fabs(tmp) >= pow(10, -8))
        {
                pai += tmp;
                i = -i;
                j += 2;
                tmp = i / (j*1.0);
               
        }
        printf("π的近似值为:%.7f", pai*4);
        return 0;
}

3.斐波那契数列?
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int Fib(int n)
{
        if (n == 1 || n == 2)
        {
                return 1;
        }
        else
        {
                return Fib(n - 1) + Fib(n - 2);
        }
}
int main()
{
        long int num;
        num = Fib(24);
        printf("两年后可以繁殖%ld对兔子", num);
        return 0;
}

adffdrtt 发表于 2024-3-30 23:21:54

0v0

ajax.han 发表于 2024-3-31 12:10:49

1

newbie12 发表于 2024-3-31 15:14:30

ui

王泽元 发表于 2024-4-6 19:14:39

10
11
a,b,c
14,5,9
z=x>0 ? x : -x



int main()
{
        int year = 1,money = 10000;
        float invest1,invest2;
       
        invest1 = money + money * 0.1 * year;
        invest2 = money * pow(1.05,year);
       
        while( invest1 >= invest2 ){
                year++;
        }
        printf("%d",year);
        return 0;
}

王泽元 发表于 2024-4-6 19:15:58

int main()
{
        int year = 1,money = 10000;
        float invest1,invest2;
       
        while( invest1 > invest2 ){
        invest1 = money + money * 0.1 * year;
        invest2 = money * pow(1.05,year);
                year++;
        }
        printf("%d",year);
        return 0;
}

王泽元 发表于 2024-4-6 19:23:15

int main()
{
        int year = 1;
        float asset = 4000000;
        while(asset>0){
                asset = (asset - 500000) * 1.08;
                year++;
        }
        printf("%d",year);
        return 0;
}

王泽元 发表于 2024-4-6 20:12:22

int F(n){
        if((n==1)||(n==2)){
                return 1;
        }
        else
        return F(n-1)+F(n-2);
}
int main()
{
        long a ;
        a = F(24);
        printf("%ld",a);
}

Michael_Lam2 发表于 2024-4-8 18:51:51

接着肝

inked 发表于 2024-4-11 13:55:47

q

y18702589513 发表于 2024-4-11 15:25:34

查看参考答案

coco别说话 发表于 2024-4-13 10:00:23

aa

shizhaohui 发表于 2024-4-13 13:14:13

好好好
页: 267 268 269 270 271 272 273 274 275 276 [277] 278 279 280 281 282 283
查看完整版本: S1E16:拾遗 | 课后测试题及答案