鱼C论坛

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

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

  [复制链接]
发表于 2026-8-20 15:38:47 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
0、10
1、10
2、a,b,c
3、a=13,b=5,c=9
4、z = (x>0)?x:-x;
5、if (size > 12){cost = cost * 1.05;flag = 2;}bill = cost * flag;
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2026-8-21 17:18:47 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2026-8-23 21:28:29 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2026-8-28 11:54:27 | 显示全部楼层
0
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2026-8-28 15:45:47 | 显示全部楼层
0
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2026-8-29 14:49:55 | 显示全部楼层
0.无限,j!=10永远成立
1.0
2.a,b,c
3.14,5,9
4.z = x >= 0 ? x : -1 * x;
5.A
if (size > 12)
{
        cost *= 1.05;
        flag = 2;
}
else
{
        bill = cost * flag;
}
B
if (ibex > 14)
{
        sheds = 3;
}
else
{
        sheds = 2;
        help = 2 * sheds;
}
C
while (score < 0)
{
        count++;
        scanf("%d", &score);
}
printf("count = %d\n", count);
0.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

int main()
{
        int i = 0;
        double a = 10000, b = 10000;
        while (a >= b)
        {
                a = a + 10000 * 0.1;
                b = b * 1.05;
                i++;
        }
        printf("%d年后,黑夜的投资总额超过小甲鱼!\n",i);
        printf("小甲鱼的投资额是:%.2lf\n", a);
        printf("黑夜的投资额是:%.2lf\n", b);

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

int main()
{
        double Pi=0, i=1, j=1;
        while (fabs(1 / i) > pow(10, -8))
        {
                Pi += 1/i*j;
                j *= -1;
                i = i + 2;
        }
        Pi *= 4;
        printf("Pi的近似值为%.7lf", Pi);

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

int main()
{
        int lr1 = 1, lr2=0, br = 0;
        for (int t = 0;t <= 24;t++)
        {
                br += lr2;
                lr2 = 0;
                lr2 += lr1;
                lr1 = 0;
                lr1 = br;
        }
        printf("两年后可以繁殖%d对兔子", lr1 + lr2 + br);

        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2026-9-4 18:09:45 | 显示全部楼层
。/
、、

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2026-9-6 20:13:10 | 显示全部楼层
81
11
abc
a=14 b=5 c=9
z = (x >= 0) ? x : -x;
--------------------
    if (size > 12)
    {
    cost = cost * 1.05;
    flag = 2;
    }
    bill = cost * flag;
--------------------
if (ibex > 14)
{
sheds = 3;
}
else{
sheds = 2;
}
help = 2 * sheds;
--------------------
while (1) {
    scanf("%d", &score);
    if (score < 0) break;
    count++;
}
printf("count = %d\n", count);
--------------------
float turtle=10000,dark=10000;int count=0;
do{
turtle=turtle+10000*0.1;
dark=dark+dark*0.05;
count=count+1;
}
while(turtle>=dark);
printf("%d %.2f %.2f",count,turtle,dark);
-------------------------
int main() {
        float turtle = 4000000;int count = 0;
        do {
                turtle = (turtle - 500000)*1.08;
                count = count + 1;
        } while (turtle > 0);
                printf("%d %.2f", count, turtle);
}
------------------------------
int main() {
        long double a = 0;
        long double add;
        int n = 1 ;long double signal = 1;
        do {
                add = signal/(2*n-1);
                a = a + add;
                n++;
                signal = -signal;
        }
        while (fabs(add)>1e-8);
        printf("%.7f", 4*a);
}
---------------------------------
#include<stdio.h>
int main() {
        int birthable = 0, all = 2, month = 0, young0 = 2,young1=0;
        while (month<24) {
                month++;
                all = all + birthable / 2 * 2;
                birthable = birthable + young1;
                young1 = young0;
                int new_born = birthable;
                young0 = new_born;
        }
        printf("%d", all);
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2026-9-7 09:19:53 | 显示全部楼层
0.10
1.10
2.a,b,c
3.3,9,12
4.z=x>0?x:-x
5.A
if(size>12)
{
     cost=cost*1.05;
flag=2;
}

   
    bill=cost*flag
C
while(1){
scanf("%d",&score);
if(score<0){
printf("count=%d",count);
}
count++;
0.
#include <stdio.h>
int main()
{
        int year=0, inte_x=10000,inte_h=10000;
        while(inte_x>=inte_h)
        {
                inte_x+=10000*0.1;
                inte_h*=1.05;
                year++;
        }
        printf("%d年后,黑夜投资额超过小甲鱼!\n",year);
        return 0;
}
1.
#include <stdio.h>
int main()
{
        int year=0,cash=400;
        while(cash>0)
        {
                cash-=50;
                cash*=1.08;
                year++;
        }
        printf("%d年后,小甲鱼再次一贫如洗...\n",year);
        return 0;
}
2.
#include <stdio.h>
int main()
{
        int i=-1;
        double re=0,num=1.0;
        while(1.0/num>0.0000000001)
        {
                i*=-1;
                re+=i/num;
                num+=2;

        }
        printf("pi=%.9f\n",re*4);
        return 0;
}
3.
#include <stdio.h>
int main()
{
        int num=1,month=0,repro=0,month1=1,month2=0;
        while(month<=24)
        {
                num+=repro;
                month2=month1;
                repro=num-month1-month2;
                month1=repro;
                month++;

        }
        printf("两年后,%d对兔子\n",num);
        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2026-9-7 14:43:02 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2026-9-7 20:21:28 | 显示全部楼层
100个A
11
a,b,c
a=14 b=5 c=9
z=x>=0? x:-x
if (size > 12)
{  cost = cost * 1.05;
        flag = 2;
}
      bill = cost * flag;

#include<stdio.h>
#include<math.h>
int main (){
    long double fourpi=0;
    int k=1;
    int sign=1;
    long double num=1;
    while (fabs(num)>=(1e-8)){
        num=1.0L/(sign*k);
        fourpi+=num;
        k+=2;
        sign=-sign;        
    }
    printf("Pi近似值为%.7Lf",4*fourpi);
    return 0;
}


while (score)<=0{
count++
scanf(.....)}
printf(.....)

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2026-9-10 15:50:39 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 7 天前 | 显示全部楼层
s'd
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 7 天前 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 7 天前 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 6 天前 | 显示全部楼层
0  100个A
1  11个B
2  abc都是左值
3  4  5  9
4  
if (size > 12) { cost = cost * 1.05; flag = 2; }
          bill = cost * flag;


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

scanf("%d", &score);
for(; !(score < 0), count++)
{ scanf("%d", &score);}
printf("count = %d\n", count);
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-18 19:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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