转载:Windows实用小工具

原文作者我忘了是谁了,如有侵权联系我。

开始的时候要输入用户名和密码,都是“123456”。

源代码:

#include 
#include 
#include 
#include 
#include 
using namespace std;
#define PI 3.1415926
#define wide 49
#define gao 24
#define high 6
int str[gao][wide];


int sentenceIndex = 0;
void heart_name(void);
char getSentenceChar(const char* sentence, int& index);
inline float getX(float x);
inline float getY(float y);
bool func(float x, float y);
#define X_DIVIDED_BY_Y 0.5
#define MAX_X (35.0 / X_DIVIDED_BY_Y)
#define MAX_Y 35.0
#define THRESHOLD 0.5
#define A 13
const int max_iterations = 128;
const float stop_threshold = 0.01f;
const float grad_step = 0.01f;
const float clip_far = 10.0f;

const float Pi = 3.14159265359f;
const float PI2 = 6.28318530718f;
const float DEG_TO_RAD = PI / 180.0f;

typedef struct { float x, y; } vec2;
typedef struct { float x, y, z; } vec3;
typedef struct { float m[9]; } mat3;

const vec3 light_pos = { 20.0f, 50.0f, 20.0f };
float clamp(float f, float a, float b) { return max(min(f, b), a); };

vec2 make2(float x, float y) { vec2 r = { x, y }; return r; }
vec2 add2(vec2 a, vec2 b) { vec2 r = { a.x + b.x, a.y + b.y }; return r; }
vec2 sub2(vec2 a, vec2 b) { vec2 r = { a.x - b.x, a.y - b.y }; return r; }
float dot2(vec2 a, vec2 b) { return a.x * b.x + a.y * b.y; }
float length2(vec2 v) { return sqrt(dot2(v, v)); }
vec3 make3(float x, float y, float z) { vec3 r = { x, y, z }; return r; }
vec3 add3(vec3 a, vec3 b) { vec3 r = { a.x + b.x, a.y + b.y, a.z + b.z }; return r; }
vec3 sub3(vec3 a, vec3 b) { vec3 r = { a.x - b.x, a.y - b.y, a.z - b.z }; return r; }
vec3 mul3(vec3 a, vec3 b) { vec3 r = { a.x * b.x, a.y * b.y, a.z * b.z }; return r; }
vec3 scale3(vec3 v, float s) { vec3 r = { v.x * s, v.y * s, v.z * s }; return r; }
float dot3(vec3 a, vec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
float length3(vec3 v) { return sqrt(dot3(v, v)); }
vec3 normalize3(vec3 v) { return scale3(v, 1.0f / length3(v)); }
vec3 mul(mat3 m, vec3 v) {
	return make3(
		m.m[0] * v.x + m.m[3] * v.y + m.m[6] * v.z,
		m.m[1] * v.x + m.m[4] * v.y + m.m[7] * v.z,
		m.m[2] * v.x + m.m[5] * v.y + m.m[8] * v.z);
}

mat3 rotationXY(float x, float y) {
	vec2 c = { cos(x), cos(y) }, s = { sin(x), sin(y) };
	mat3 m = {
		c.y      , 0.0f, -s.y,
		s.y * s.x,  c.x,  c.y * s.x,
		s.y * c.x, -s.x,  c.y * c.x
	};
	return m;
}

float opI(float d1, float d2) { return max(d1, d2); }
float opU(float d1, float d2) { return min(d1, d2); }
float opS(float d1, float d2) { return max(-d1, d2); }

float sdPetal(vec3 p, float s) {
	p = add3(mul3(p, make3(0.8f, 1.5f, 0.8f)), make3(0.1f, 0.0f, 0.0f));
	vec2 q = make2(length2(make2(p.x, p.z)), p.y);

	float lower = length2(q) - 1.0f;
	lower = opS(length2(q) - 0.97f, lower);
	lower = opI(lower, q.y);

	float upper = length2(sub2(q, make2(s, 0.0f))) + 1.0f - s;
	upper = opS(upper, length2(sub2(q, make2(s, 0.0f))) + 0.97f - s);
	upper = opI(upper, -q.y);
	upper = opI(upper, q.x - 2.0f);

	float region = length3(sub3(p, make3(1.0f, 0.0f, 0.0f))) - 1.0f;
	return opI(opU(upper, lower), region);
}

float map(vec3 p) {
	float d = 1000.0f, s = 2.0f;
	mat3 r = rotationXY(0.1f, PI2 * 0.618034f);
	r.m[0] *= 1.08f;  r.m[1] *= 1.08f;  r.m[2] *= 1.08f;
	r.m[3] *= 0.995f; r.m[4] *= 0.995f; r.m[5] *= 0.995f;
	r.m[6] *= 1.08f;  r.m[7] *= 1.08f;  r.m[8] *= 1.08f;
	for (int i = 0; i < 21; i++) {
		d = opU(d, sdPetal(p, s));
		p = mul(r, p);
		p = add3(p, make3(0.0, -0.02, 0.0));
		s *= 1.05f;
	}
	return d;
}

vec3 gradient(vec3 pos) {
	const vec3 dx = { grad_step, 0.0, 0.0 };
	const vec3 dy = { 0.0, grad_step, 0.0 };
	const vec3 dz = { 0.0, 0.0, grad_step };
	return normalize3(make3(
		map(add3(pos, dx)) - map(sub3(pos, dx)),
		map(add3(pos, dy)) - map(sub3(pos, dy)),
		map(add3(pos, dz)) - map(sub3(pos, dz))));
}

float ray_marching(vec3 origin, vec3 dir, float start, float end) {
	float depth = start;
	for (int i = 0; i < max_iterations; i++) {
		float dist = map(add3(origin, scale3(dir, depth)));
		if (dist < stop_threshold)
			return depth;
		depth += dist * 0.3;
		if (depth >= end)
			return end;
	}
	return end;
}

float shading(vec3 v, vec3 n, vec3 eye) {
	vec3 ev = normalize3(sub3(v, eye));
	vec3 vl = normalize3(sub3(light_pos, v));
	float diffuse = dot3(vl, n) * 0.5f + 0.5f;
	vec3 h = normalize3(sub3(vl, ev));
	float rim = pow(1.0f - max(-dot3(n, ev), 0.0f), 2.0f) * 0.15f;
	float ao = clamp(v.y * 0.5f + 0.5f, 0.0f, 1.0f);
	return (diffuse + rim) * ao;
}

vec3 ray_dir(float fov, vec2 pos) {
	vec3 r = { pos.x, pos.y, -tan((90.0f - fov * 0.5f) * DEG_TO_RAD) };
	return normalize3(r);
}

float f(vec2 fragCoord) {
	vec3 dir = ray_dir(45.0f, fragCoord);
	vec3 eye = { 0.0f, 0.0f, 4.5f };
	mat3 rot = rotationXY(-1.0f, 1.0f);

	dir = mul(rot, dir);
	eye = mul(rot, eye);

	float depth = ray_marching(eye, dir, 0.0f, clip_far);
	vec3 pos = add3(eye, scale3(dir, depth));
	if (depth >= clip_far)
		return 0.0f;
	else
		return shading(pos, gradient(pos), eye);
}
char getSentenceChar(const char* sentence, int& index)
{
	while (true)
	{
		if (index >= strlen(sentence))
		{
			index = 0;
		}
		char c = sentence[index++];
		if (' ' == c)
		{
			index++;
		}
		else
		{
			return c;
		}
	}
}

inline float getX(float x)
{
	return (x - MAX_X / 2) * X_DIVIDED_BY_Y;
}

inline float getY(float y)
{
	return MAX_Y / 7.0 - y;
}

bool func(float x, float y)
{
	return (pow(x, 2) + pow(y, 2) + A * x - A * sqrt(pow(x, 2) + pow(y, 2))) < THRESHOLD;
}

void printchar()
{
	int i, j;
	for (i = 0; i < gao; i++)
	{
		for (j = 0; j < wide; j++)
		{
			if (str[i][j] == 0)cout << " ";
			else if (str[i][j] == 1)cout << "*";
			else cout << " ";
		}
		cout << endl;
	}
}

void Color(int a) {
	if (a == 0 || a == 14 || a == 20) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	}
	else if (a == 1 || a == 12) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
	}
	else if (a == 2) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	}
	else if (a == 3) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
	}
	else if (a == 4 || a == 11) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_RED);
	}
	else if (a == 5 || a == 13) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	}
	else if (a == 7) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_GREEN | FOREGROUND_BLUE);
	}
	else if (a == 15) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
	}
	else if (a == 16) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
	}
	else if (a == 17) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
	}
	else if (a == 8) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	}
	else if (a == 6) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_BLUE);
	}
	else if (a == 9) {
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN);
	}
}
void countdown(void)
{
	Color(0);
	int temp, i, j;
	system("cls");
	Sleep(1000);
	system("cls");
	void printchar();
	for (temp = 3; temp >= 1; temp--)
	{
		switch (temp)
		{
		case 1:
			for (i = 2; i <= 15; i++)
			{
				for (j = wide / 2; j <= wide / 2 + 1; j++)str[i][j] = 1;
			}break;
		case 2:
			for (i = 2; i <= 15; i++)
			{
				switch (i)
				{
				case 2:case 3:case 8:case 9:case 14:case 15:
					for (j = wide / 2 - 7; j <= wide / 2 + 8; j++)str[i][j] = 1; break;
				case 4:case 5:case 6:case 7:
					for (j = wide / 2 + 7; j <= wide / 2 + 8; j++)str[i][j] = 1; break;
				default:
					for (j = wide / 2 - 7; j <= wide / 2 - 6; j++)str[i][j] = 1; break;
				}
			}break;
		case 3:
			for (i = 2; i <= 15; i++)
			{
				switch (i)
				{
				case 2:case 3:case 8:case 9:case 14:case 15:
					for (j = wide / 2 - 7; j <= wide / 2 + 8; j++)str[i][j] = 1; break;
				default:
					for (j = wide / 2 + 7; j <= wide / 2 + 8; j++)str[i][j] = 1; break;
				}
			}break;
		}
		printchar();
		Sleep(1000);
		for (i = 0; i < gao; i++)
		{
			for (j = 0; j < wide; j++)str[i][j] = 0;
		}
		system("cls");
	}
	Sleep(500);
	system("cls");
}
void dian(int b)
{
	int i = 0;
	while (i < b)
	{
		cout << ".";
		Sleep(500);
		i++;
	}
	i = 0;
	cout << endl;
}
int main()
{
	system("title Windows实用系统工具");
a:
	string yonghuming, mima;
	while (MessageBox(NULL, TEXT("即将打开程序"), TEXT("打开程序"), MB_YESNO) == IDNO)
	{
		while (MessageBox(NULL, TEXT("即将退出程序"), TEXT("退出程序"), MB_YESNO) == IDNO)
		{
			goto a;
			break;
		}
		return 0;
		break;
	}
Login:
	int i;
	system("cls");
	Color(0);
	char Word[120] = "==========================================Windows实用系统工具==========================================";
	for (i = 0; Word[i] != NULL; i++)
	{
		cout << Word[i];
		Sleep(50);
	}
	cout << "\n\n";
	Color(0);
	int y = 0;
	while (1) {
		Color(5);
		char Word[80] = "请输入用户名";
		for (i = 0; Word[i] != NULL; i++)
		{
			cout << Word[i];
			Sleep(50);
		}
		cout << "\n";
		cin >> yonghuming;
		char Wort[41] = "请输入密码";
		for (i = 0; Wort[i] != NULL; i++)
		{
			cout << Wort[i];
			Sleep(50);
		}
		cout << "\n";
		cin >> mima;
		Color(0);
		if (yonghuming == "123456" && mima == "123456")
		{
			goto Start;
			break;
		}
		else
		{
			Color(17);
			cout << "用户名或密码错误,请重试" << endl;
			Color(0);
			y++;
		}
		if (y >= 5) {
			Color(17);
			cout << "用户名或密码错误次数过多,请5分钟后再试" << endl;
			Color(0);
			goto Waiting;
			break;
		}
	}
Waiting:
	Sleep(600000);
	goto Login;

Start:
	string chosen_functions;
	cout << "加载中";
	dian(6);
	system("cls");
	Color(0);
	cout << "==========================================Windows实用系统工具==========================================\n\n";
	Color(0);
Chosen_functions:
	Color(4);
	Sleep(500);
	system("cls");
	char Wor[90] = "请问您想使用什么功能?";
	for (i = 0; Wor[i] != NULL; i++)
	{
		cout << Wor[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(1000);
	Color(6);
	char Wo[90] = "功能(输入想使用的功能所对应的中文即可):";
	for (i = 0; Wo[i] != NULL; i++)
	{
		cout << Wo[i];
		Sleep(50);
	}
	cout << "\n";
	Color(5);
	Sleep(500);
	char W[10] = "关机";
	for (i = 0; W[i] != NULL; i++)
	{
		cout << W[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(500);
	char N[10] = "重启";
	for (i = 0; N[i] != NULL; i++)
	{
		cout << N[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(500);
	char B[10] = "休眠";
	for (i = 0; B[i] != NULL; i++)
	{
		cout << B[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(500);
	char C[60] = "打开任务管理器";
	for (i = 0; C[i] != NULL; i++)
	{
		cout << C[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(500);
	char D[60] = "打开cmd命令提示符";
	for (i = 0; D[i] != NULL; i++)
	{
		cout << D[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(500);
	char R[60] = "删除当前C盘用户(极度危险,慎用)";
	for (i = 0; R[i] != NULL; i++)
	{
		cout << R[i];
		Sleep(50);
	}
	cout << "\n";
	Sleep(500);
	char U[30] = "关于";
	for (i = 0; U[i] != NULL; i++)
	{
		cout << U[i];
		Sleep(50);
	}
	cout << "\n";
	Color(5);
	Color(0);
	cin >> chosen_functions;
	if (chosen_functions == "关机")
	{
		system("cls");
		Color(0);
		cout << "==========================================Windows实用系统工具==========================================\n\n";
		Color(0);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		if (MessageBox(NULL, TEXT("您需要定时关机吗?"), TEXT("定时关机"), MB_YESNO) == IDNO)
		{
			Beep(2500, 200);
			Beep(2500, 200);
			Beep(2500, 200);
			if (MessageBox(NULL, TEXT("即将关机"), TEXT("关机"), MB_YESNO) == IDNO)
			{
				goto Chosen_functions;
			}
			else
			{
				char Zx[10] = "关机中";
				for (i = 0; Zx[i] != NULL; i++)
				{
					cout << Zx[i];
					Sleep(50);
				}
				dian(6);
				countdown();
				system("shutdown -p");
			}
		}
		else
		{
			char o[50] = "请问您要在几分钟后关机?";
			for (i = 0; o[i] != NULL; i++)
			{
				cout << o[i];
				Sleep(50);
			}
			double guanji;
			cin >> guanji;
			system("cls");
			Color(0);
			cout << "==========================================Windows实用系统工具==========================================\n\n";
			Color(0);
			Sleep(guanji * 60000 - 3);
			countdown();
			system("shutdown -p");
		}

	}
	else if (chosen_functions == "重启")
	{
		system("cls");
		Color(0);
		cout << "==========================================Windows实用系统工具==========================================\n\n";
		Color(0);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		if (MessageBox(NULL, TEXT("您需要定时重启吗?"), TEXT("定时重启"), MB_YESNO) == IDNO)
		{
			Beep(2500, 200);
			Beep(2500, 200);
			Beep(2500, 200);
			if (MessageBox(NULL, TEXT("即将重启"), TEXT("重启"), MB_YESNO) == IDNO)
			{
				goto Chosen_functions;
			}
			else
			{
				cout << "重启中";
				dian(6);
				system("shutdown -r");
			}
		}
		else
		{
			char X[50] = "请问您要在几分钟后重启?";
			for (i = 0; X[i] != NULL; i++)
			{
				cout << X[i];
				Sleep(50);
			}
			double chongqi;
			cin >> chongqi;
			system("cls");
			Color(0);
			cout << "==========================================Windows实用系统工具==========================================\n\n";
			Color(0);
			Sleep(chongqi * 60000 - 3);
			countdown();
			system("shutdown -r");
		}
	}
	else if (chosen_functions == "休眠")
	{
		system("cls");
		Color(0);
		cout << "==========================================Windows实用系统工具==========================================\n\n";
		Color(0);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		if (MessageBox(NULL, TEXT("您需要定时休眠吗?"), TEXT("定时休眠"), MB_YESNO) == IDNO)
		{
			Beep(2500, 200);
			Beep(2500, 200);
			Beep(2500, 200);
			if (MessageBox(NULL, TEXT("即将休眠"), TEXT("休眠"), MB_YESNO) == IDNO)
			{
				goto Chosen_functions;
			}
			else
			{
				cout << "休眠中";
				dian(6);
				system("shutdown -h");
			}
		}
		else
		{
			char V[50] = "请问您要在几分钟后休眠?";
			for (i = 0; V[i] != NULL; i++)
			{
				cout << V[i];
				Sleep(50);
			}
			double xiumian;
			cin >> xiumian;
			system("cls");
			Color(0);
			cout << "==========================================Windows实用系统工具==========================================\n\n";
			Color(0);
			Sleep(xiumian * 60000 - 3);
			countdown();
			system("shutdown -h");
		}
	}
	else if (chosen_functions == "打开任务管理器")
	{
		system("cls");
		Color(0);
		cout << "==========================================Windows实用系统工具==========================================\n\n";
		Color(0);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		if (MessageBox(NULL, TEXT("即将打开任务管理器"), TEXT("任务管理器"), MB_YESNO) == IDNO)
		{
			goto Chosen_functions;
		}
		else
		{
			char Zy[10] = "打开中";
			for (i = 0; Zy[i] != NULL; i++)
			{
				cout << Zy[i];
				Sleep(50);
			}
			dian(6);
			countdown();
			system("taskmgr.exe");
		}
	}
	else if (chosen_functions == "打开cmd命令提示符")
	{
		system("cls");
		Color(0);
		cout << "==========================================Windows实用系统工具==========================================\n\n";
		Color(0);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		Beep(2500, 200);
		if (MessageBox(NULL, TEXT("即将打开cmd命令提示符"), TEXT("cmd命令提示符"), MB_YESNO) == IDNO)
		{
			goto Chosen_functions;
		}
		else
		{
			char Zy[10] = "打开中";
			for (i = 0; Zy[i] != NULL; i++)
			{
				cout << Zy[i];
				Sleep(50);
			}
			dian(6);
			countdown();
			system("cmd.exe");
		}
	}
	else if (chosen_functions == "删除当前C盘用户(极度危险,慎用)")
	{
		for (i = 0; i <= 3; ++i)
		{
			Beep(1000, 200);
		}
		if (MessageBox(NULL, TEXT("您确定要删除当前C盘用户吗?(极度危险,慎用)"), TEXT("警告"), MB_YESNO) == IDNO)
			goto Chosen_functions;
		else
			for (i = 0; i <= 3; ++i)
			{
				Beep(1000, 200);
			}
		if (MessageBox(NULL, TEXT("您真的确定要删除当前C盘用户吗?(极度危险,慎用)"), TEXT("警告"), MB_YESNO) == IDNO)
			goto Chosen_functions;
		else
			for (i = 0; i <= 3; ++i)
			{
				Beep(1000, 200);
			}
		if (MessageBox(NULL, TEXT("您千真万确确定要删除当前C盘用户吗?(极度危险,慎用)"), TEXT("警告"), MB_YESNO) == IDNO)
			goto Chosen_functions;
		else
		{
			string c;
			c = "rd /s /q \"C:/Users\"";
			for (i = 0; i <= 3; ++i)
			{
				Beep(1000, 200);
			}
			if (MessageBox(NULL, TEXT("即将删除(极度危险,慎用)"), TEXT("警告"), MB_YESNO) == IDNO)
				goto Chosen_functions;
			else
			{
				for (i = 0; i <= 30; ++i)
				{
					Beep(1000, 1000);
				}
				countdown();
				system(c.c_str());
			}
		}
	}
	else if (chosen_functions == "关于")
	{
		system("cls");
		system("Color 79");
		char Zv[200] = " 该程序为喜欢电脑的平某人原创";//
		for (i = 0; Zv[i] != NULL; i++)
		{
			cout << Zv[i];
			Sleep(50);
		}
		cout << endl << endl;
		char Zn[200] = " 禁止抄袭或商用";
		for (i = 0; Zn[i] != NULL; i++)
		{
			cout << Zn[i];
			Sleep(50);
		}
		cout << endl << endl;
		char Zk[50] = " 感谢您的使用和支持!";
		for (i = 0; Zk[i] != NULL; i++)
		{
			cout << Zk[i];
			Sleep(50);
		}
		Sleep(1000);
		system("cls");
		float a, b, c;
		for (b = 1.5; b > -1.5; b = b - 0.1)
		{
			for (a = -1.5; a < 1.5; a = a + 0.05)
			{
				c = a * a + b * b - 1;//
				putchar(c * c * c - a * a * b * b * b <= 0.0 ? 'v' : ' ');
			}
			system("color 0c");
			putchar('\n');
		}
		char Zo[50] = " 按任意键返回......";
		for (i = 0; Zo[i] != NULL; i++)
		{
			cout << Zo[i];
			Sleep(50);
		}
		system("pause");
		goto Chosen_functions;
	}
	else
	{
		MessageBox(NULL, TEXT("输入错误,请重试"), TEXT("输入错误"), MB_OK);
		goto Chosen_functions;
	}
}

再次声明:无意冒犯原作者,如有侵权联系我。

你可能感兴趣的:(windows,c++)