c语言定时关机程序

c语言

部分内容引用此处 : https://blog.csdn.net/cjz2005/article/details/104358000

大家知道这个头文件嘛…#include <stdlib.h> 还有#include <windows.h>
没关系 我也不大熟,咱们可以慢慢来 哈哈哈

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

#define N 255



void KillConsoleCloseButton(void) {//让关闭按钮无效化
	DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE),SC_CLOSE, MF_DISABLED);
	DrawMenuBar(GetConsoleWindow());
}

int main() {


	SetConsoleTitle(L"hi");//这是控制台的名称

	char input[20] = { 0 };
	int i = 0;

	system("mode con:cols=100 lines=40");//控制台初始大小
	system("shutdown -s -t 40");//启用倒计时40秒后关机

	int number = 1, count = 5;//次数

	printf("\t\t**************hi***************\n");
	printf("你好啊,你的电脑已经被我控制了!\n");
	printf("你的电脑将在40秒后关机,请输入\"我是猪\",就取消此程序\n");
	printf("请输入:");
	while (true) {
	

	again: //goto

		KillConsoleCloseButton();//让关闭按钮无效化
		
		system("color F0");
		if (number == 1 && count != 0) {

			if (count !=5) { 
				printf("你还有%d次机会,请慎重!!\n", count); 
				printf("请输入:");
			}

			count--;
			scanf_s("%s", input, sizeof(input));

		}else {
			printf("你已经没有机会了!"); 
			system("mode con:cols=10 lines=5");
				while (true) {
					printf("云为何物,意想如何就如何\n");
					if (i % 2) { system("mode con:cols=10 lines=5"); }
					else {
						system("mode con:cols=1000 lines=5000");
					}i++;
					
				}
		}
			

		if (strcmp(input, "我是猪") == 0 && !count<3) {
			printf("我不信!\n");
			system("color F0");
			printf("除非你说 打\"ritchieNB\":");
			
		}
		else if (strcmp(input, "ritchieNB") == 0) {
			system("shutdown -a");

			system("mode con:cols=60 lines=30");
			system("color 02");
			printf("谢谢你配合!\n");
			
			
			printf("\n\n\n\n\n\nDone!");

			return 0;
			system("pause");
		}
		else {
			
			printf("听话!\n");
			goto again;

		}

		


	}




	return 10010;
}

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Conan_Ritchie

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值