鱼C论坛

 找回密码
 立即注册
查看: 2280|回复: 2

[已解决]while 语句

[复制链接]
发表于 2020-3-10 20:56:37 | 显示全部楼层 |阅读模式
2鱼币
  1. #include <stdio.h>

  2. #define MONEY   10000

  3. int main()
  4. {
  5.         double a_total = MONEY, b_total = MONEY;
  6.         int count = 0;

  7.         <font color="Red">do
  8.         {
  9.                 a_total += MONEY * 0.1;
  10.                 b_total += b_total * 0.05;
  11.                 count++;
  12.         } while(a_total >= b_total);</font>

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

  16.         return 0;
  17. }




  18. #include <stdio.h>

  19. #define MONEY   10000

  20. int main()
  21. {
  22.         double a_total = MONEY, b_total = MONEY;
  23.         int count = 0;

  24.        <font color="Red">while(a_total >= b_total);
  25.         {
  26.                 a_total += MONEY * 0.1;
  27.                 b_total += b_total * 0.05;
  28.                 count++;
  29.         }
  30. </font>
  31.         printf("%d年后,黑夜的投资额超过小甲鱼!\n", count);
  32.         printf("小甲鱼的投资额是:%.2f\n", a_total);
  33.         printf("黑夜的投资额是:%.2f\n", b_total);

  34.         return 0;
  35. }
复制代码

为何变了一下就没有办法输出数据了?

最佳答案
2020-3-10 20:56:38
while(a_total >= b_total);
复制的很完美。一字不差

最佳答案

查看完整内容

while(a_total >= b_total); 复制的很完美。一字不差
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-3-10 20:56:38 | 显示全部楼层    本楼为最佳答案   
while(a_total >= b_total);
复制的很完美。一字不差
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-3-10 21:07:35 | 显示全部楼层
把while的分号去掉
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-1 04:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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