啊哈磊_编程从这里起步

标题: 新手,请教,谢谢! [打印本页]

作者: zhyuw1030    时间: 2018-2-9 10:06
标题: 新手,请教,谢谢!
更进一步,99页的两分钟倒计时怎么写?新手,谢谢!
2:00,这个不知道怎么弄

作者: 逸飞扬_VbCNT    时间: 2018-2-9 10:06
本帖最后由 逸飞扬_VbCNT 于 2018-2-10 10:03 编辑
zhyuw1030 发表于 2018-2-10 09:33
书上的内容没学到那么多,有没有再简单的?

[mw_shl_code=c,true]#include <stdio.h>#include <stdlib.h>
#include<windows.h>
int main()
{
    int m,s;

    printf("2:00");
    for(m=1;m>=0;m--)
    {

        for(s=59;s>=0;s--)
        {

            Sleep(995);//延时减少以使时间更准确
            if(s>9)
            {system("cls");
                printf("%d:%d",m,s);}
            else
            {system("cls");
                printf("%d:0%d",m,s);
            }   
        }

    }
    system("pause > nul");
    return 0;
}
}[/mw_shl_code]

作者: 逸飞扬_VbCNT    时间: 2018-2-9 13:48
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
    int m,s;
    const COORD pos={0,0};
    CONSOLE_CURSOR_INFO cursor_info = {1,0};
    SetConsoleCursorInfo(
        GetStdHandle(STD_OUTPUT_HANDLE),
        &cursor_info);//隐藏光标
    printf("2:00");
    for(m=1;m>=0;m--)
        for(s=59;s>=0;s--)
        {
            SetConsoleCursorPosition(
                GetStdHandle(STD_OUTPUT_HANDLE),
                pos);//设置位置
            Sleep(995);//延时减少以使时间更准确
            if(s>9)
                printf("%d:%d",m,s);
            else
                printf("%d:0%d",m,s);
        }
    system("pause > nul");
    return 0;
}
作者: 陈运123    时间: 2018-2-9 19:40
#include <stdio.h> #include <stdlib.h> #include <windows.h> int main() {         int a;     a=90;     while(a>=0)     {            system("cls");         printf("%d",a);         Sleep(1000);         a=a-1;              }     printf("90秒倒计时结束,已经浪费你九十秒人生");         system("pause");         return 0; }
作者: 陈运123    时间: 2018-2-9 19:41
while.c (263 Bytes, 下载次数: 0)

源代码
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
        int a;
    a=90;
    while(a>=0)
    {   
        system("cls");
        printf("%d",a);
        Sleep(1000);
        a=a-1;

    }
    printf("90秒倒计时结束,已经浪费你九十秒人生");
        system("pause");
        return 0;
}



作者: zhyuw1030    时间: 2018-2-10 09:33
逸飞扬_VbCNT 发表于 2018-2-9 13:48
#include
#include
#include

书上的内容没学到那么多,有没有再简单的?
作者: zhyuw1030    时间: 2018-2-10 09:38
陈运123 发表于 2018-2-9 19:41
源代码
#include
#include

你这种不符合题目 的格式,要求是2:00、1:59、1:58.......1:00、0:59、0:58......0:00,这里只学了while ,if,if-while, Sleep(),system("cls");其他的都还没有学到

作者: 738389368    时间: 2018-2-12 16:02
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
system ("color 0a");
        int a,b,c;
    a=2;b=0;c=0;
    printf("%d:%d%d",a,b,c);
    Sleep(1000);
    a=a-1;
    while(a>=0)
    {
        b=5;
        while(b>=0)
        {
                        c=9;
            while(c>=0)
            {
            system("cls");
            printf("%d:%d%d",a,b,c);
            Sleep(1000);
            c=c-1;
            }
        b=b-1;
        }
    a=a-1;
    }
        system("pause");
        return 0;
}[/mw_shl_code]




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