目录
諾需求:
代码:
效果:
諾需求:
关机程序 要程序运行起来,电脑就在1分钟内关机,如果输入:我是猪,就取消关机。
代码:
#include#include #include int main() { char input[23] = { 0 }; system("shutdown -s -t 60");//system是一个库函数,是用来执行系统命令的 again: printf("请注意,你的电脑在1分钟内关机,如果输入:我是猪,就取消关机n"); scanf("%s", input); //判断 if(strcmp(input,"我是猪") == 0) { system("shutdown -a");//取消关机 } else { goto again; } return 0; } #include#include #include int main() { char input[23] = { 0 }; system("shutdown -s -t 60");//system是一个库函数,是用来执行系统命令的 while (1) { printf("请注意,你的电脑在1分钟内关机,如果输入:我是猪,就取消关机n"); scanf("%s", input); //判断 if (strcmp(input, "我是猪") == 0) { system("shutdown -a");//取消关机 break; } } return 0; }
效果:
(江湖游历在外,还要多多仰仗各位衣食父母,方便的话点个赞,点个关注呗,谢谢你嘞,客官慢走)



