赞
踩
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- int main(){
- int time1;
- char input[20]={0};
- system("shutdown -s -t 60");//执行自动关机操作,包含于头文件stdlib.h 后面的60为60秒后关机
- time1=(int)time(NULL)+60;//截取时间戳,用于之后计算计算剩余关机时间 该函数包含于time.h
- while(1){
- printf("您的计算机将在%d秒后关机!\n输入 我是猪 取消关机!\n",time1-(int)time(NULL));
- scanf("%s",input);
- if(strcmp(input,"我是猪")==0){//strcmp用于比较字符串,如果字符串相同时返回0;string.h
- system("shutdown -a");
- break;
- }
- else{
- printf("输入错误!\n");
- }
- }
- printf("OK,我已经知道你是猪了,不用再重复了!");
- return 0;
- }

先上代码
可以用编译器编译,将生成的.exe发给朋友,当朋友点击这个文件时,电脑进入自动关机状态,当朋友输入“我是猪”时,电脑才会取消自动关机,快去恶搞一下你的朋友吧哈哈。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。