//关机程序
1、电脑运行起来后,1分钟内关机。
2、如果输入:我是猪。就取消关机。
#include<stdio.h>
#include<string.h>
int main()
{
char input[20] = { 0 };
system("shutdown -s -t 60");
again:
printf("请注意,你的电脑在60秒内关机。如果输入我是猪,就取消关机\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)
{
system("shutdown -a");
}
else
{
goto again;
}
return 0;
}
用while语句替换文章来源:https://uudwc.com/A/X3rNe
#include<string.h>
int main()
{
char input[20] = { 0 };
system("shutdown -s -t 60");
while (1)
{
printf("请注意,你的电脑在60秒内关机。如果输入我是猪,就取消关机\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)
{
system("shutdown -a");
break;
}
}
return 0;
}文章来源地址https://uudwc.com/A/X3rNe