| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 972 人关注过本帖
标题:这个关机程序怎么加入倒计时显示?
只看楼主 加入收藏
我是过来人灬
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-12-1
结帖率:100%
收藏
 问题点数:0 回复次数:3 
这个关机程序怎么加入倒计时显示?
程序代码:
#include<stdio.h>

 #include<string.h>

 #include<stdlib.h>
#include<time.h>


 int main()
  {
      char cmd[20]="shutdown -s -t ";  /* -t后面留一个空格  */ 
      char t[5]="\0";
      int c;

      system("title 小可爱专用关机");  
      system("mode con cols=48 lines=25");   
      system("color f0");
      system("date/T");
      system("time/t");


      printf("-----------C语言关机程序-----------\n");
      printf("1.实现10分钟内的定时关闭计算机\n");
      printf("2.立即关闭计算机\n");
      printf("3.注销计算机\n");
      printf("0.退出系统\n");
      printf("------------------------------------\n");
      scanf("%d",&c);
      
      switch(c){
      case 1:
          printf("您想在多少秒后自动关机?(0~600)\n");
      scanf("%s",t);       /* t前不需要&  */ 
      system(strcat(cmd,t));break;                    /* 这里怎么改? */
      case 2:
          system("shutdown -p");break;
      case 3:
          system("shutdown -l");break;
      case 0:
          break;
      default:
          printf("Error\n");
      }
      system("pause");
      return 0;
  } 


 下面是我对倒计时的想法。
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<time.h>
int main()
{printf("t:");

 int s=0;
scanf("%d",&s);
int i;
for(i=s;i>=0;i--)
{printf("\r倒计时:%3d",i);
Sleep(1000);
}
exit(0);}


当然也可以用别的方法写。谢谢大侠们了。
搜索更多相关主题的帖子: color 
2016-12-16 23:45
我是过来人灬
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-12-1
收藏
得分:0 
试了下,这样能倒计时 。但是不准确。
程序代码:
#include<stdio.h>

 #include<string.h>

 #include<stdlib.h>
#include<time.h>
#include<windows.h>



 int main()
  {
      char cmd[20]="shutdown -s -t ";  /* -t后面留一个空格  */ 
      char t[5]="\0";
      int c;

      system("title 小可爱专用关机");  
      system("mode con cols=48 lines=25");   
      system("color f0");
      system("date/T");
      system("time/t");


      printf("-----------C语言关机程序-----------\n");
      printf("1.实现10分钟内的定时关闭计算机\n");
      printf("2.立即关闭计算机\n");
      printf("3.注销计算机\n");
      printf("0.退出系统\n");
      printf("------------------------------------\n");
      scanf("%d",&c);
      
      switch(c){
      case 1:
          printf("您想在多少秒后自动关机?(0~600)\n");
      scanf("%s",t);       /* t前不需要&  */ 
      system(strcat(cmd,t));
            char *p;
      gets(t);
     for(p=t;p>=0;p--)     
     {printf("\r 倒计时:%3d",p);
     Sleep(1000);}break;
      case 2:
          system("shutdown -p");break;
      case 3:
          system("shutdown -l");break;
      case 0:
          break;
      default:
          printf("Error\n");
      }
      system("pause");
      return 0;
  } 
2016-12-17 00:34
我是过来人灬
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-12-1
收藏
得分:0 
可能代码长了。我简略点。求修改。
程序代码:
#include<stdio.h>
  #include<string.h>
  #include<stdlib.h>
#include<time.h>

  int main()
   {
       char cmd[20]="shutdown -s -t ";  /* -t后面留一个空格  */ 
       char t[5]="\0";
       int c;

       system("title 小可爱专用关机");  
       system("mode con cols=48 lines=25");   
       system("color f0");
       system("date/T");
       system("time/t");


       printf("-----------C语言关机程序-----------\n");
       printf("1.实现10分钟内的定时关闭计算机\n");
     
       printf("------------------------------------\n");
       scanf("%d",&c);
       
       switch(c){
       case 1:
           printf("您想在多少秒后自动关机?(0~600)\n");
       scanf("%s",t);       /* t前不需要&  */ 
       system(strcat(cmd,t));break;                    /* 这里怎么改? */
     
       default:
           printf("Error\n");
       }
       system("pause");
       return 0;
   } 

2016-12-20 20:38
我是过来人灬
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2016-12-1
收藏
得分:0 
没人回。。看来还是得靠自己研究。
2016-12-26 22:57
快速回复:这个关机程序怎么加入倒计时显示?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021803 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved