啊哈磊_编程从这里起步

标题: 我想弄一个倒计时120s的程序,为什么显示可以运行但是什么都没有 [打印本页]

作者: xcy    时间: 2019-4-18 01:27
标题: 我想弄一个倒计时120s的程序,为什么显示可以运行但是什么都没有
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. int main()
  5. {
  6.     int a;
  7.     a=60;
  8.     system("color 72");
  9.     while(a>=0);
  10.     {
  11.         system("cls");
  12.         printf("%d",a);
  13.         a=a-1;
  14.         Sleep(1000);
  15.     }
  16.     system("pause");
  17.     return 0;
  18. }





复制代码

作者: 也有    时间: 2019-4-25 20:14
本帖最后由 也有 于 2019-4-25 20:18 编辑

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
    int a;
    a=60;
    system("color 72");
    while(a>=0);//这里应改成while(a>=0),你加了分号
    {
        system("cls");
        printf("%d",a);
        a=a-1;
        Sleep(1000);
    }
    system("pause");
    return 0;
}
作者: chenyitan    时间: 2019-4-25 21:52
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
    int a=60;
    system("color 72");
        for(int i=60;i>=0;i--)
        {
                a--;
                system("cls");
        printf("%d",a);
        Sleep(1000);
        }
           
   
    system("pause");
    return 0;
}




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2