鱼C论坛

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

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

  [复制链接]
发表于 2025-12-11 11:30:55 | 显示全部楼层
零基础入门学习C语言封面
《零基础入门学习C语言》
小甲鱼 著
立即购买
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2025-12-11 17:50:50 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2025-12-12 20:25:57 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2025-12-20 09:30:50 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2025-12-22 14:19:03 | 显示全部楼层
1
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2025-12-24 16:33:16 | 显示全部楼层
0.10
1.0
2.a b c
3.13 3 8
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;
}
sheds = 2;
help = 2 * sheds;
C.do{
        readin: scanf("%d", &score);
        printf("count = %d\n", count);
        count++;
}while(score < 0)
0.#include <stdio.h>
int main()
{
        float xjy=10000,hy=10000;
        int i;
        do
        {
                xjy+=1000;
                hy*=1.05;
                i++;
        }while(hy<xjy);
        printf("%d年后,黑夜的投资额超过小甲鱼!\n",i);
        printf("小甲鱼的投资额是:%.2f\n",xjy);
        printf("黑夜的投资额是:%.2f\n",hy);
        return 0;
}      
1.#include <stdio.h>
int main()
{
        int s=400,i=0;
        do
        {
                s-=50;
                s*=1.08;
                i++;
        }while(s>0);
        printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......",i);
}
2.#include <stdio.h>
int main()
{
        double pi=0;
        double fz=1,fm=1,s=0;
        int sign=1;
        do
        {
                s+=(fz*sign)/fm;
                fm+=2;
                sign=-sign;
        }while((fz/fm)>1e-8);
        pi=4*s;
        printf("%.7f",pi);
        return 0;
}
3.#include <stdio.h>
int main()
{
        int s1=1,s2=1,i=0;
        do
        {
                s1+=s2;
                s2+=s1;
                i++;
        }while(i<11);
        printf("%d",s2);
        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

使用道具 举报

发表于 昨天 13:50 | 显示全部楼层
10
10
c = 5, b = c, a = b
14 5 9
if  (x < 0) { z = -x; } else if (x > 0) { z = x; }
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++}
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4.     int count = 1, TF = 1;
  5.     double x, y;
  6.     do {
  7.         x = 10000 * 0.1 * count + 10000;
  8.         y = 10000 * pow((1 + 0.05), count);
  9.         if (x < y){
  10.             TF = 0;
  11.         }
  12.         count++;
  13.     } while (TF);
  14.    
  15.     printf("%d年后,黑夜的投资额超过小甲鱼!\n", count - 1);
  16.     printf("小甲鱼的投资额是:%.2f\n", x);
  17.     printf("黑夜的投资额是:%.2f\n", y);

  18.     return 0;
  19. }
复制代码
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4.     double base = 4000000.0;
  5.     int count = 1;
  6.     do {
  7.         base = (base - 500000.0) * (1 + 0.08);
  8.         count++;
  9.     } while (base >= 0);
  10.     printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗……\n", count - 1);

  11.     return 0;
  12. }
复制代码
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4.     int count=0, num = 1, i=1;
  5.     double sum=0.0;
  6.     double term;
  7.     do {
  8.         term = (double)1 / num;
  9.         sum += i * term;
  10.         i = -i;
  11.         num += 2;
  12.     } while (fabs(term) >= pow(10, -8));
  13.     printf("Pi的近似值为%.7lf", sum * 4);

  14.     return 0;
  15. }
复制代码
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4.     int parent = 2, child1 = 0, child2 = 0;
  5.     int time;
  6.     for (time = 0; time < 24; time++)
  7.     {
  8.         parent += child2;
  9.         child2 = child1;
  10.         child1 = parent / 2;
  11.     }
  12.     printf("两年后可以繁殖出%d对", child1 / 2);
  13.     return 0;
  14. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-2 07:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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