实现一个可以关闭电脑的小程序,闲余时间可以恶搞一下朋友,恶搞还可以继续增加趣味和难度。下面是我写的比较简单的关机小程序:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char input[10];

    system("shutdown -s -t 60");
flag:
    printf("提示:一分钟之后关机,请输入\"我是猪\",三个字,否则就关机!!!\n");
    scanf("%s", input);
    if (strcmp("我是猪", input) == 0)
    {
        system("shutdown -a");
    }
    else
    {
        goto flag;
    }
    return 0;
}