Skip to content

Commit 5597cd5

Browse files
authored
Update 定时关机小程序.c
1 parent b4cdcd7 commit 5597cd5

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

经典项目/定时关机小程序.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
#
1+
#include<stdio.h>
2+
#include<string.h>
3+
#include<stdlib.h>
4+
5+
void main()
6+
{
7+
char cmd[20]="shutdown -s -t ";
8+
char t[5]="0";
9+
int c;
10+
11+
system("title C语言关机程序"); //设置cmd窗口标题
12+
system("mode con cols=48 lines=25"); //窗口宽度高度
13+
system("color f0"); //可以写成 red 调出颜色组
14+
system("date /T");
15+
system("TIME /T");
16+
17+
printf("----------- C语言关机程序 -----------\n");
18+
printf("1.实现10分钟内的定时关闭计算机\n");
19+
printf("2.立即关闭计算机\n");
20+
printf("3.注销计算机\n");
21+
printf("0.退出系统\n");
22+
printf("-------------------------------------\n");
23+
24+
scanf("%d",&c);
25+
switch(c) {
26+
case 1:
27+
printf("您想在多少秒后自动关闭计算机?(0~600)\n");
28+
scanf("%s",t);
29+
system(strcat(cmd,t));
30+
break;
31+
case 2:
32+
system("shutdown -p");
33+
break;
34+
case 3:
35+
system("shutdown -l");
36+
break;
37+
case 0:
38+
break;
39+
default:
40+
printf("Error!\n");
41+
}
42+
system("pause");
43+
return 0;
44+
}

0 commit comments

Comments
 (0)