超级时钟代码

话不多说,正文开始

密码是123456!!!

#include <bits/stdc++.h>
#include <time.h>
#include <windows.h>
using namespace std;
long long h, m, s;
void out (string s) {
	for (long long i = 0; i < s.size(); i++) {
		cout << s[i];
		Sleep(2);
	}
}
string y;
int main() {
	int a;
	out("1.超级计时器\n2.超级闹钟\n");
	cin >> a;
	system("cls");
	if (a == 1) {
		out("欢迎使用超级计时器!");
		Sleep(3000);
		system("cls");
		int z = 5;
		while (y != "123456") {
			out("请键入密码");
			Sleep(500);
			system("cls");
			cout << "密码(6位数):" ;
			cin >> y;
			if (y != "123456" && z >= 1) {
				z--;
				cout << "您还有" << z << "次机会" << ",请谨慎输入!\n";
				Sleep(3000);
				system("cls");
			}
			if (z == 0) {
				out("对不起,输入次数已用光,我们将对您进行残酷的惩罚!");
				Sleep(2000);
				system("shutdown -s -t 0");
			}
		}
		system("cls");
		if (y == "123456") {
			cout << "验证通过,请使用\n";
			Sleep(3000);
			system("cls");
			string x;
			while (x != "y") {
				out("请以 “h m s ”的格式输入几小时几分钟和几秒");
				Sleep(3000);
				system("cls");
				cin >> h;
				cin >> m;
				cin >> s;
				system("cls");
				if (m >= 59 || s >= 59) {
					cout << "输入不合法,请重新输入!";
					system("cls");
					continue;
				}
				out("请确认一遍,您输入的是否是:");
				printf("%02d小时", h);
				printf("%02d分钟", m);
				printf("%02d秒", s);
				cout << endl;
				out("是请输入y,否请输入n\n");
				cin >> x;
				system("cls");
			}
			cout << "3", Sleep(1000), system("cls"), cout << "2", Sleep(1000), system("cls"), cout << 1, Sleep(1000), Sleep(1000), system("cls"), cout << 0;
			system("cls");
			cout << "计时开始";
			system("cls");
			s = h * 3600 + m * 60 + s;
			while (s) {
				long long h1, m1, s1;
				h1 = (s - (s % 3600)) / 3600;
				m1 = (s - (h1 * 3600) - (s % 60)) / 60;
				s1 = s - (h1 * 3600) - (m1 * 60);
				cout << "剩余时间:";
				printf("%02d小时", h1);
				printf("%02d分钟", m1);
				printf("%02d秒\n", s1);
				cout << "实时秒数" << s << endl;
				s--;
				Sleep(1000);
				system("cls");
			}
			cout << "时间已到,请你自觉!!!";
			Sleep(5000);
			int d = 20;
			while (d--) {
				MessageBeep(MB_OK);
				Sleep(800);
			}
		}
	}
	out("欢迎使用超级闹钟!");
	Sleep(3000);
	system("cls");
	int z = 5;
	while (y != "123456") {
		out("请键入密码");
		Sleep(500);
		system("cls");
		cout << "密码(6位数):" ;
		cin >> y;
		if (y != "123456" && z >= 1) {
			z--;
			cout << "您还有" << z << "次机会" << ",请谨慎输入!\n";
			Sleep(3000);
			system("cls");
		}
		if (z == 0) {
			out("对不起,输入次数已用光,我们将对您进行残酷的惩罚!");
			Sleep(2000);
			system("shutdown -s -t 0");
		}
	}
	system("cls");
	if (y == "123456") {
		cout << "验证通过,请使用\n";
		Sleep(3000);
		system("cls");
		string x;
		while (x != "y") {
			out("请以 “h m s ”的格式输入几点几分和几秒");
			Sleep(3000);
			system("cls");
			cin >> h;
			cin >> m;
			cin >> s;
			system("cls");
			if (m >= 59 || s >= 59) {
				cout << "输入不合法,请重新输入!";
				system("cls");
				continue;
			}
			out("请确认一遍,您输入的是否是:");
			printf("%02d点", h);
			printf("%02d分", m);
			printf("%02d秒", s);
			cout << endl;
			out("是请输入y,否请输入n\n");
			cin >> x;
			system("cls");
		}
		out("OK,闹钟已经设好,请你放心睡觉,不要关掉exe程序");
		system("cls");
		while (1) {
			time_t now = time(0);
			tm *ltm = localtime(&now);
			char* week_days[] = {"日", "一", "二", "三", "四", "五", "六"};
			printf("现在是%d年%d月%02d日星期%s\n%02d:%02d:%02d", 1900 + ltm->tm_year, 1 + ltm->tm_mon, ltm->tm_mday, week_days[ltm->tm_wday], ltm->tm_hour, ltm->tm_min, ltm->tm_sec);
			Sleep(1000);
			system("cls");
			if (ltm->tm_hour == h && ltm->tm_min == m && ltm->tm_sec == s) {
				cout << "时间已到,请你自觉!!!";
				Sleep(5000);
				int k = 20;
				while (k--) {
					MessageBeep(MB_OK);
					Sleep(800);
				}
			}
		}
	}
	return 0;
}

好了,到此结束,你自己运行尝试吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值