题目要求
用C语言编写一个关机程序
程序分析
系统提示一分钟之后关机,如果输入“我爱你”就注销关机,否则将跳到关机程序,继续提示,如果一分钟之内输入不对,则关机。
主要程序
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char input[20];
system ("shutdown -s -t 60");
again:
printf ("你的电脑将在60秒之后关机,如果输入我是猪,就取消关机。\n");
scanf ("%s",input);
if (strcmp(input,"我是猪") == 0 )
{
system("shutdown -a");
}
else
{
goto again;
}
return 0;
}