雨如洁 发表于 2020-3-10 20:56:37

while 语句

#include <stdio.h>

#define MONEY   10000

int main()
{
      double a_total = MONEY, b_total = MONEY;
      int count = 0;

      <font color="Red">do
      {
                a_total += MONEY * 0.1;
                b_total += b_total * 0.05;
                count++;
      } while(a_total >= b_total);</font>

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

      return 0;
}




#include <stdio.h>

#define MONEY   10000

int main()
{
      double a_total = MONEY, b_total = MONEY;
      int count = 0;

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

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

ba21 发表于 2020-3-10 20:56:38

while(a_total >= b_total);
复制的很完美。一字不差

qiuyouzhi 发表于 2020-3-10 21:07:35

把while的分号去掉
页: [1]
查看完整版本: while 语句