搜索
查看: 638|回复: 7
打印 上一主题 下一主题

新手,请教,谢谢!

[复制链接]
跳转到指定楼层
楼主
发表于 2018-2-9 10:06:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5啊哈币
更进一步,99页的两分钟倒计时怎么写?新手,谢谢!
2:00,这个不知道怎么弄

最佳答案

查看完整内容

[mw_shl_code=c,true]#include #include #include 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); ...
沙发
发表于 2018-2-9 10:06:55 | 只看该作者
本帖最后由 逸飞扬_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]
板凳
发表于 2018-2-9 13:48:14 | 只看该作者
#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;
}
地板
发表于 2018-2-9 19:40:29 | 只看该作者
#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; }
5#
发表于 2018-2-9 19:41:29 | 只看该作者
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;
}


6#
 楼主| 发表于 2018-2-10 09:33:21 | 只看该作者
逸飞扬_VbCNT 发表于 2018-2-9 13:48
#include
#include
#include

书上的内容没学到那么多,有没有再简单的?
7#
 楼主| 发表于 2018-2-10 09:38:02 | 只看该作者
陈运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");其他的都还没有学到
8#
发表于 2018-2-12 16:02:34 | 只看该作者
[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]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表