跳到正文

剪贴板

剪贴板 7lspl4rx

原文
剪贴板信息

剪贴板信息

收录
更新
C++
#include<bits/stdc++.h>
#include <windows.h>
#include <winternl.h>
#include <conio.h>
using namespace std;
bool mp[150][150];
bool hot[150][150];
int getcolor(string str)
{
	if(str=="dark black")
	{
		return 0;
	}
	else if(str=="dark blue")
	{
		return 1;
	}
	else if(str=="dark green")
	{
		return 2;
	}
	else if(str=="dark cyan")
	{
		return 3;
	}
	else if(str=="dark red")
	{
		return 4;
	}
	else if(str=="dark purple")
	{
		return 5;
	}
	else if(str=="dark yellow")
	{
		return 6;
	}
	else if(str=="dark white")
	{
		return 7;
	}
	else if(str=="light black")
	{
		return 8;
	}
	else if(str=="light blue")
	{
		return 9;
	}
	else if(str=="light green")
	{
		return 10;
	}
	else if(str=="light cyan")
	{
		return 11;
	}
	else if(str=="light red")
	{
		return 12;
	}
	else if(str=="light purple")
	{
		return 13;
	}
	else if(str=="light yellow")
	{
		return 14;
	}
	else if(str=="light white")
	{
		return 15;
	}
	else
	{
		return 0;
	}
}
void setcolor(string str2="light white",string str1="dark black")
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),getcolor(str1)*16+getcolor(str2));
}
void setcolor(int int2=15,int int1=0)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),int1*16+int2);
}
void getmap()
{
	srand(time(0));
	for(int i=2;i<=59;i+=3)
	{
		for(int j=2;j<=59;j+=3)
		{
			if(rand()%2)
			{
				mp[i][j]=1;
				if(i>=3 && mp[i-3][j])
				{
					mp[i-1][j+1]=1;
					mp[i-1][j-1]=1;
					mp[i-1][j]=1;
					mp[i-2][j+1]=1;
					mp[i-2][j-1]=1;
					mp[i-2][j]=1;
				}
				if(j>=3 && mp[i][j-3])
				{
					mp[i+1][j-1]=1;
					mp[i][j-1]=1;
					mp[i-1][j-1]=1;
					mp[i+1][j-2]=1;
					mp[i][j-2]=1;
					mp[i-1][j-2]=1;
				}
			}
		}
	}
	for(int i=2;i<=59;i+=3)
	{
		for(int j=2;j<=59;j+=3)
		{
			if(rand()%3)
			{
				hot[i][j]=1;
				if(i>=3 && hot[i-3][j])
				{
					hot[i-1][j+1]=1;
					hot[i-1][j-1]=1;
					hot[i-1][j]=1;
					hot[i-2][j+1]=1;
					hot[i-2][j-1]=1;
					hot[i-2][j]=1;
				}
				if(j>=3 && hot[i][j-3])
				{
					hot[i+1][j-1]=1;
					hot[i][j-1]=1;
					hot[i-1][j-1]=1;
					hot[i+1][j-2]=1;
					hot[i][j-2]=1;
					hot[i-1][j-2]=1;
				}
			}
		}
	}
	return;
}
int main()
{
	getmap();
	for(int i=1;i<=60;i++)
	{
		for(int j=1;j<=60;j++)
		{
			string color;
			if(hot[i][j])
			{
				color="light ";
			}
			else
			{
				color="dark ";
			}
			if(mp[i][j])
			{
				color=color+"green";
			}
			else
			{
			    color=color+"blue";
			}
			setcolor(color);
			cout<<"+";
		}
		cout<<endl;
	}
	setcolor("light white");
	return 0;
}