#include <stdio.h>
#include <stdlib.h>
#include <string.h>int main()
{char input[20] = {0};system("shutdown -s -t 60");//system是一个库函数,是用来执行系统命令的
again:printf("请注意,你的电脑在1分钟内关机,如果输入:我是猪,就取消关机n");scanf_s("%s", input);//判断if (strcmp(input, "我是猪") == 0){system("shutdown -a");//取消关机}else{goto again;}return 0;
}//主要使用了goto语句,用别的循环语句也行或者用while语句int main()
{char input[20] = { 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;
}
这个代码非常有意思,可以去试一下
本文发布于:2024-02-01 01:51:01,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170672346232993.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |