跳到正文

剪贴板

剪贴板 exhtm30b

WOL_GO
原文
剪贴板信息

剪贴板信息

发布
收录
更新

一号系统3.1.1

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<unistd.h>
using namespace std;
ofstream fout;
const int maxn=1e6+5;
vector<string>_main_;
string mn,colour;
void color(int a){
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void gotoxy(int x,int y) { 
	COORD coord;
	coord.X=x-1;
	coord.Y=y-1;
	SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );
}
void hide(){ 
	CONSOLE_CURSOR_INFO cursor_info={1,0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
int Rand(int l,int r){
	return rand()%(r-l+1)+l;
}
void sprint(string s){
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		if(s[i]!='\n'&&s[i]!=' ')Sleep(1);
	}
}
void start(){
//	cout<<"欢迎来到一号系统\nWelcome to System One\n";
//	Sleep(1500);
	sprint("\n\n\n\n\n\n\n                                                                                                   \n                                                                              ,`      .]           \n                                      @@@@@@@@@@@@@^    O@@@@@@@@@@@@@@@@.   ,@/      .@@.         \n                                      @@         =@^         ]@@[    ,].    ,@/  \@@@\@\@@@@@@`    \n                                      @@@@@@@@@@@@@^     .]@@`  ..]/@@`    ,@^ =@^  /@`  ,@`       \n               *******************`   [`         ...    .@@@[[[\@@/`,      \@@@@` ,@/   ..=@\      \n               \[[[[[[[[[[[[[[[[[\^\[[[@@[[[[[[[[[[[[\^    ,/@@[.   \@\`     /@` ,@@@@[[@@[[@\     \n                                      =@\]]]]]]]]]]]    =@@@@@@@@@@@@@@@@` ,@@]@@^  =@  @@         \n                                      ,[[[[[[[[[[`@^       ,\   @@ ./`  ,. ,[.     .@/  @@  .`     \n                                                 =@^     /@/`   @@  .\@@`  ]]@@@@/.@@.  @@  =@^    \n                                          =@@@@@@@/   .@@/  =@@@@/     ,@/ ,.  .]@@/    =@@@@@.    \n                                                                                .                  \n                                                                                                   \n");
//	for(int i=0;i<=100;i++){
//		Sleep(500);
//		system("cls");
//		i+=Rand(1,5);
//		cout<<"Loading:";
//		for(int j=1;j<=i/10;j++)cout<<"=";
//		cout<<min(i,100)<<"%\n";
//	}
	Sleep(1500);
	system("cls");
	return ;
}
void checkkey(){
	if(access("tmp.txt",F_OK)){
		fout.open("tmp.txt");
		fout<<"123456\n7\n";
		fout.close();
	}
	cout<<"请输入密码\n";
	string s="123456",s1;
	freopen("tmp.txt","r",stdin);
	getline(cin,s1);
	mn=s1;
	cin>>colour;
	freopen("CON","r",stdin);
	getline(cin,s);
	string tmpp="color "+colour;
	system(tmpp.c_str());
	system("cls");
//	cerr<<1;
	if(s!=s1)exit(0);
	cout<<"密码验证成功\n";
	Sleep(3000);
	system("cls");
}
void init(){
	_main_.push_back("设置");
	_main_.push_back("浏览器");
	_main_.push_back("保存并退出");
	_main_.push_back("游戏");
	_main_.push_back("快捷操作");
	_main_.push_back("画板");
}
void control(){
	cout<<"1、设置颜色\n2、修改密码\n3、版本信息\n4、官方下载地址\n5、重置系统\n";
	int col=getch()-'0';
	system("cls");
	if(col==1){
		system("color g");
		getch();
		cin>>colour;
		fout.close();
		remove("tmp.txt");
		ofstream fout("tmp.txt");
		fout<<mn<<"\n"<<colour<<"\n";
		string tmpp="color "+colour;
		system(tmpp.c_str());
	}
	else if(col==2){
		cout<<"请输入密码\n";
		cin>>mn;
		fout.close();
		remove("tmp.txt");
		ofstream fout("tmp.txt");
		fout<<mn<<"\n"<<colour<<"\n";
		string tmpp="color "+colour;
		system(tmpp.c_str());
	}
	else if(col==3){
		cout<<"一号系统\nThe First System\n3.1.1版\n作者:wol_qwq\n侵权必究\n";
		getch();
	}
	else if(col==4){
		system("start https://www.luogu.com.cn/paste/exhtm30b");
	}
	else if(col==5){
		remove("tmp.txt");
		exit(0);
	}
	system("cls");
}
void fast(){
	cout<<"1、极域trainner下载(需登录洛谷)\n2、作者主页\n";
	char c=getch()-'0';
	if(c==1)system("start https://www.luogu.com.cn/fe/api/problem/downloadAttachment/tqa8i3an");
	else if(c==2)system("start https://www.luogu.com.cn/user/999081");
}
int co1[1005][1005];
char wal[1005][1005];
void draw(){
	#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0X8000) ? 1:0)
	HWND h=GetForegroundWindow();
	HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);
	HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_FONT_INFO consoleCurrentFont;
	char zi='#';int co2=7;
	CONSOLE_SCREEN_BUFFER_INFO csbi;
    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
	int xx=csbi.srWindow.Right-csbi.srWindow.Left+1,yy=csbi.srWindow.Bottom-csbi.srWindow.Top + 1;
    for(int i=0;i<=1004;i++)for(int j=0;j<=1004;j++)co1[i][j]=7,wal[i][j]=' ';
    cout<<"右键进入菜单(按任意键退出此提示并开始作画)\n";
    getch();
    system("cls"); 
	while(1){
		if(KEY_DOWN(VK_LBUTTON)) {
	        POINT p;
	        GetCursorPos(&p);
	        ScreenToClient(h,&p);
	        GetCurrentConsoleFont(hOutput,FALSE,&consoleCurrentFont);
	        int x,y; 
	        x=p.x/=consoleCurrentFont.dwFontSize.X;
	        y=p.y/=consoleCurrentFont.dwFontSize.Y;
	        if(x<1||y<1||x>=xx||y>=xx)continue;
//	        cout<<x<<" "<<y<<"\n";
	        co1[x][y]=co2;
	        wal[x][y]=zi;
	        color(co2);
	        gotoxy(x+1,y+1);
	        cout<<zi;
	    }
	    if(KEY_DOWN(VK_RBUTTON)) {
	    	system("cls");
	        cout<<"1、切换字符\n2、切换颜色\n3、退出\n4、导出";
	        char c=getch()-'0';
	        if(c==1){
	        	system("cls");
	        	cout<<"请输入字符\n";
	        	system("cls");
	        	zi=getch();
	        	cout<<"切换成功\n";
	        	Sleep(3000);
	        	system("cls");
			}
			else if(c==2){
				system("cls");
	        	cout<<"请输入颜色\n0、黑色 1、蓝色 2、绿色 3、浅蓝色 4、红色 5、紫色 6、黄色 7、白色\n";
	        	co2=getch()-'0';
	        	color(co2);
				system("cls");
	        	cout<<"切换成功\n";
	        	Sleep(3000);
	        	system("cls");
			}
			else if(c==3){
				return ;
			}
			else if(c==4){
				system("cls");
				cout<<"请输入文件名\n";
				string fl_name;
				getline(cin,fl_name);
				fout.close();
				ofstream fout2(fl_name.c_str());
//				cout<<xx<<" "<<yy<<"\n";
				for(int i=0;i<=yy;i++){
					for(int j=0;j<=xx;j++){
						fout2<<wal[j][i];
					}
					fout2<<"\n";
				}
//				for(int i=0;i<=yy;i++){
//					for(int j=0;j<=xx;j++){
//						cout<<wal[j][i];
//					}
//				}
				fout2.close();
				getch();
				system("cls");
				cout<<"保存成功\n";
				system("cls");
			}
			system("cls");
			for(int i=0;i<=1004;i++)for(int j=0;j<=1004;j++){
			 	if(co1[i][j]!=7||wal[i][j]!=' ')gotoxy(i,j),color(co1[i][j]),cout<<wal[i][j];
			}
	    }
	}
	#undef KEY_DOWN(VK_NONAME)
}
void browser(){
	cout<<"请输入网址或搜索内容\n";
	string site = "";
    cin>>site;
    string command = "ping "+site+" -n 1 > tmp2.txt";
    system(command.c_str()); 
    freopen("tmp2.txt","r",stdin);
    char ch;
    cin>>ch;
    freopen("CON","r",stdin);
    remove("tmp2.txt");
    if(ch!='P'){
        site="start "+site;
		system(site.c_str());
    }
	else{
		site="start https://cn.bing.com/search?q="+site;
		system(site.c_str());
	}
}
#define black 0
#define yellow 1
#define red 2
#define blue 3
#define green 4
#define jin 10
#define p2 11
#define change 12
const int plmax=15;
int player;
int sti(string s){
    bool t=0;
    int ans=0;
    if(s[0]=='-')t=1;
    else s=" "+s;
    for(int i=1;i<s.size();i++)ans=ans*10+(s[i]-'0');
    return t?-ans:ans;
}
struct acard{
    int num,col,dig;
};
struct card{
    acard car[1000];
};
struct pai{
    acard back;
    int pai[5][15][2];card pla[100];//颜色,数字,第几张,黑色0-1表示转色,2-3表示+4,数值表示在哪个玩家手中
    int cnt[100]={0},tp=1,plusp=0,turn=1;
    bool b=1;
    void init(){
        for(int i=0;i<=4;i++){
            for(int j=0;j<12;j++){
                for(int l=0;l<=1;l++)pai[i][j][l]=0;
            }
        }
        memset(cnt,0,sizeof(cnt));
        b=1,tp=1,plusp=0,turn=1;
        memset(pla,0,sizeof(pla));
        for(int i=4;i<=14;i++)pai[black][i][0]=pai[black][i][1]=plmax+5;
        for(int i=13;i<=14;i++){
            for(int j=1;j<=4;j++){
                pai[j][i][0]=pai[j][i][1]=plmax+5;
            }
        } 
        while(1){
            int x=rand()%5,y=rand()%13,z=rand()%2;
            if(x==0&&y>=4)continue;
            if(!pai[x][y][z]&&y<=9&&x!=black){
                pai[x][y][z]=-1;
                back.num=y;
                back.col=x;
                back.dig=z;
                break;
            }
        }
        cout<<"底牌:"<<pcard(back.num,back.col)<<"\n";
        color(7);
        return ;
    }
    string pcard(int num,int col){
        string s="";
        if(col==1)s+="黄",color(6);
        else if(col==2)s+="红",color(4);
        else if(col==3)s+="蓝",color(1);
        else if(col==4)s+="绿",color(2);
        else /*if(col==0)*/{
            if(num==0||num==1)s+="转色";
            else s+="+4";
            color(3);           
            return s;
        }
        if(num<=9)s+=to_string(num);
        else if(num==10)s+="禁止";
        else if(num==11)s+="+2";
        else if(num==12)s+="转换顺序";
        else if(num==13)s+="(转色得来)";
        else if(num==14)s+="(+4牌)";
        return s;
    }
    void fapai(){
        for(int i=1;i<=player;i++){
            while(cnt[i]<7){
                int x=rand()%5,y=rand()%13,z=rand()%2;
                if(x==0&&y>=4)continue;
                if(!pai[x][y][z]){
                    pai[x][y][z]=i;
                    pla[i].car[++cnt[i]].num=y;
                    pla[i].car[cnt[i]].col=x;
                    pla[i].car[cnt[i]].dig=z;
                }
            }
        }
    }
    void print(){
        for(int i=1;i<=player;i++){
            for(int j=1;j<=cnt[i];j++){
                cout<<pcard(pla[i].car[j].num,pla[i].car[j].col)<<"\n";
                color(7);
            }
            putchar('\n');
        }
    }
    void printp(int x){
        for(int j=1;j<=cnt[x];j++){
            cout<<j<<"、"<<pcard(pla[x].car[j].num,pla[x].car[j].col)<<"\n";
            color(7);
        }
    }
    void lp(int x){
        cout<<"玩家"<<x<<"出了"<<pcard(back.num,back.col)<<"\n";
        color(7);
    }
    bool del(int x,int y){
        pai[pla[x].car[y].col][pla[x].car[y].num][pla[x].car[y].dig]=-1;
        for(int i=y;i<=cnt[x]-1;i++){
            pla[x].car[i].num=pla[x].car[i+1].num;
            pla[x].car[i].col=pla[x].car[i+1].col;
            pla[x].car[i].dig=pla[x].car[i+1].dig;
        }
        cnt[x]--;
        if(cnt[x]==1){
            cout<<"玩家"<<x<<"喊出了UNO\n";
            getch();
        }
        if(cnt[x]==0){
//            if(pla[x].car[y].col==black||pla[x].car[y].num>=10){
//                cout<<"由于玩家"<<x<<"的最后一张牌为功能牌,自动为其摸一张\n";
//                add(x);
//                return ;
//            }
            lp(x);
            cout<<"玩家"<<x<<"获胜\n";
            getch();
            return 1;
        }
        return 0;
    }
    void add(int pl){
        while(1){
            bool wash=1;
            for(int i=0;i<=4;i++){
                for(int j=0;j<12;j++){
                    for(int l=0;l<=1;l++)if(pai[i][j][l]==0)wash=0;
                }
            }
            if(wash){
                cout<<"没牌了,系统开始洗牌\n";
                for(int i=0;i<=4;i++){
                    for(int j=0;j<12;j++){
                        for(int l=0;l<=1;l++)if(pai[i][j][l]==-1)pai[i][j][l]=0;;
                    }
                }
            }
            int x=rand()%5,y=rand()%13,z=rand()%2;
            if(x==0&&y>=4)continue;
            if(!pai[x][y][z]){
                pai[x][y][z]=pl;
                pla[pl].car[++cnt[pl]].num=y;
                pla[pl].car[cnt[pl]].col=x;
                pla[pl].car[cnt[pl]].dig=z;
                break;
            }
        }
    }
    bool check(acard back,acard now){
        if(pai[back.col][back.num][back.dig]==plmax+5)pai[back.col][back.num][back.dig]=0;
        if(now.col==black){
            return 1;
        }
        if(now.num==back.num){
            return 1;
        }
        if(now.col==back.col){
            return 1;
        }
        return 0;
    }
    void ctp(int x){
        if(x==1)tp+=turn;
        if(tp<=0)tp=player+tp;
        if(tp>player)tp-=player;
    }
    void gop(int x,int xxx){
        acard y=pla[x].car[xxx==-1?100:xxx];
        if(plusp!=0){
            string s;
            if(back.num==11)s="+2";
            else s="+4";
            //            cout<<"请出"<<s<<",否则摸牌,摸牌-1,出牌请直接输出第x张牌\n";
            //            int m;
            //            cin>>m;
            if(xxx==-1){
                pluspp:
                for(int i=1;i<=plusp;i++)add(x);
                b=0;
                plusp=0;
                ctp(1);
            }
            else{
                if(((pla[x].car[xxx].num==2||pla[x].car[xxx].num==3)&&pla[x].car[xxx].col==black)||pla[x].car[xxx].num==p2){
                    if(s=="+4"){
                        cout<<"请输入要转的颜色,黄色为1,红色为2,蓝色为3,绿色为4\n";
                        int xx;
                        cin>>xx;
                        back={14,xx,1};
                        plusp+=4;
                    }
                    else plusp+=2,back=pla[x].car[xxx];
                    if(del(x,xxx))return ;
                    ctp(1);
                }
                else goto pluspp;
            }
        }
        else if(!check(back,y))return ;//
        else {
            if(xxx==-1){
                add(x);
                ctp(1);
                b=0;
            }
            else {
                //                if(y.col==)
                if(y.num==p2){
                    plusp=2;
                    back=y;
                    ctp(1);
                }
                else if(y.num==jin){
                    back=y;
                    ctp(1);
                    ctp(1);
                }
                else if(y.num==change){
                    turn*=-1;
                    back=y;
                    ctp(1);
                }
                else if(y.col==black){
                    if(y.num==0||y.num==1){
                        cout<<"请输入要转的颜色,黄色为1,红色为2,蓝色为3,绿色为4\n";
                        int xx;
                        cin>>xx;
                        back={13,xx,1};
                        ctp(1);
                    }
                    if(y.num==2||y.num==3){
                        cout<<"请输入要转的颜色,黄色为1,红色为2,蓝色为3,绿色为4\n";
                        plusp=4;
                        int xx;
                        cin>>xx;
                        back={14,xx,1};
                        ctp(1);
                    }
                }
                else back=y,ctp(1);
                if(del(x,xxx))return ;
            }
        }
    }
    int ckp(card x,int y,int pla){
        if(!y)return 0;
        acard tback=x.car[y];
        for(int i=y;i<=cnt[pla]-1;i++){
            x.car[i]=x.car[i+1];
        }
        int ans=0;
        for(int i=1;i<=cnt[pla]-1;i++){
            if(check(tback,x.car[i]))ans++;
        }
        return ans;
    }
    void ai(int x){
        if(plusp!=0){
            if(back.num==p2){
                for(int i=1;i<=cnt[x];i++){
                    if(pla[x].car[i].num==p2){
                        back=pla[x].car[i];
                        if(del(x,i))return ;
                        ctp(1);
                        plusp+=2;
                        cout<<"玩家"<<x<<"压了你的牌\n";
                        return ;
                    }
                }
                for(int i=1;i<=plusp;i++)add(x);
                plusp=0;
                ctp(1);
                cout<<"玩家"<<x<<"选择了摸牌\n";
                b=0;
            }
            else{
                for(int i=1;i<=cnt[x];i++){
                    if((pla[x].car[i].num==2||pla[x].car[i].num==3)&&pla[x].car[i].col==black){
                        int col[5]={1};
                        for(int j=1;j<=cnt[x];j++){
                            if(pla[x].car[j].col!=black)col[pla[x].car[j].col]++;
                        }
                        for(int j=1;j<=4;j++)if(col[j]==max(col[1],max(col[2],max(col[3],col[4]))))col[0]=j;
                        back={14,col[0],1};
                        if(del(x,i))return ;
                        ctp(1);
                        plusp+=4;
                        cout<<"玩家"<<x<<"压了你的牌\n";
                        return ;
                    }
                }
                for(int i=1;i<=plusp;i++)add(x);
                plusp=0;
                ctp(1);
                cout<<"玩家"<<x<<"选择了摸牌\n";
                b=0;
            }
        }
        else{
            bool can=0;
            for(int i=1;i<=cnt[x];i++){
                if((pla[x].car[i].num==back.num&&pla[x].car[i].col!=black)||pla[x].car[i].col==back.col||pla[x].car[i].col==black)can=1;
            }
            if(!can){
                add(x);
                ctp(1);
                cout<<"玩家"<<x<<"选择了摸牌\n";
                b=0;
            }
            else{
                int choose=0;
                for(int i=cnt[x];i>=1;i--){
                    if(pla[x].car[i].col!=black&&check(back,pla[x].car[i])){
                        if(ckp(pla[x],i,x)>ckp(pla[x],choose,x)||choose==0){
//                            cout<<1;
                            choose=i;
                        }
                    }
                }
                if(choose){
                    back=pla[x].car[choose];
                    ctp(1);
                    if(pla[x].car[choose].num==p2){
                        plusp=2;
                    }
                    if(pla[x].car[choose].num==jin){
                        ctp(1);
                    }
                    if(pla[x].car[choose].num==change){
                        turn*=-1;
                        ctp(1);
                        ctp(1);
                    }
                    if(del(x,choose))return ;
                    return ;
                }
                else{
                    for(int i=cnt[x];i>=1;i--){
                        if(pla[x].car[i].col==black&&(pla[x].car[i].num==0||pla[x].car[i].num==1)){
                            int col[5]={1};
                            for(int j=1;j<=cnt[x];j++){
                                if(pla[x].car[j].col!=black)col[pla[x].car[j].col]++;
//                                cout<<col[pla[x].car[j].col]<<" "<<pla[x].car[j].col<<"\n"; 
                            }
                            for(int j=1;j<=4;j++)if(col[j]==max(col[1],max(col[2],max(col[3],col[4]))))col[0]=j;
                            back={13,col[0],1};
                            if(del(x,i))return ;
                            ctp(1);
                            return ;
                        }
                    }
                    for(int i=cnt[x];i>=1;i--){
                        if(pla[x].car[i].col==black){
                            int col[5]={1};
                            for(int j=1;j<=cnt[x];j++){
                                if(pla[x].car[j].col!=black)col[pla[x].car[j].col]++;
//                                cout<<col[pla[x].car[j].col]<<" "<<pla[x].car[j].col<<"\n"; 
                            }
                            for(int j=1;j<=4;j++)if(col[j]==max(col[1],max(col[2],max(col[3],col[4]))))col[0]=j;
                            back={14,col[0],1};
                            plusp=4;
                            if(del(x,i))return;
                            ctp(1);
                            return ;
                        }
                    }
                    add(x);
                    ctp(1);
                    cout<<"玩家"<<x<<"选择了摸牌\n";
                    b=0;
                    return ;
                }
            }
        }
    }
    bool cmp(acard x,acard y){
        return x.col==y.col?x.num==y.num?x.dig<y.dig:x.num<y.num:x.col<y.col;
    }
    void sort(){
        for(int i=1;i<=cnt[tp];i++){
            for(int j=1;j<=cnt[tp];j++){
                if(i!=j&&cmp(pla[tp].car[i],pla[tp].car[j]))swap(pla[tp].car[i],pla[tp].car[j]);
            }
        }
    }
    bool game(){
        init();
        fapai();
        //    p.print();
        while(1){
            cout<<"轮到玩家"<<tp<<"了\n";
            int tp2=tp;
            sort();
            for(int i=1;i<=cnt[tp];i++){
                for(int j=1;j<=cnt[tp];j++){
                    if(i!=j&&cmp(pla[tp].car[i],pla[tp].car[j]))swap(pla[tp].car[i],pla[tp].car[j]);
                }
            }
            if(tp==1/*||p.tp==2*/){
                if(plusp!=0){
                    cout<<"你现在正在被加牌哦(目前需要摸"<<plusp<<"张)\n";
                }
                printp(tp);
                cout<<"摸牌请按-1\n";
                cout<<"输入-2重开\n";
                string s;
                int x;
                cin>>s;
                bool k=1;
                for(int i=0;i<s.size();i++){
                    if(!isdigit(s[i])&&(s[i]!='-'||i)){k=0;break;}
                }
                if(!k){
                    cout<<"输入错误,请重新输入\n";
                    continue;
                }
                x=sti(s);
                if(x==-2){
                    system("cls");
                    return 0;
                }
                if((x>=100||x<=0)&&x!=-1)continue;
                gop(tp,x);
            }
            else{
                ai(tp);
            }
            if(b)lp(tp2);
			if(cnt[tp2]==0)return 1;
            b=1;
            cout<<"玩家"<<tp2<<"还剩余"<<cnt[tp2]<<"张牌\n";
            Sleep(500);
            //        cout<<p.tp<<" "<<p.turn<<" "<<p.plusp<<" "<<p.b<<"\n";
        }
    }
};
void UNO(){
    start:
    cout<<"请输入玩家人数\n";
    srand(time(0));
    cin>>player;
    pai p;
    if(!p.game())goto start;
    else{
    	system("cls");
    	return;
	}
}
#undef black
#undef yellow
#undef red
#undef blue
#undef green
#undef jin
#undef p2
#undef change
#define rand Rand
int bu=0;
const int e=50;
char mg[e][e],mg1[e][e];
bool use[e+1][e];
int u[e+1][e];
int dfs(int x,int y,int x1,int y1){
    if(u[x][y])return u[x][y];
    if(use[x][y])return 0;
    use[x][y]=1;
    if(!x&&!y){
//        mg[x][y]='*';
        u[x][y]=1;
        return 1;
    }
    int ans=1e9;
    if(x&&mg[x-1][y]!='#'&&x1!=x-1)if(dfs(x-1,y,x,y))ans=min(ans,dfs(x-1,y,x,y));
    if(x<e-1&&mg[x+1][y]!='#'&&x1!=x+1)if(dfs(x+1,y,x,y))ans=min(ans,dfs(x+1,y,x,y));
    if(y&&mg[x][y-1]!='#'&&y1!=y-1)if(dfs(x,y-1,x,y))ans=min(ans,dfs(x,y-1,x,y));
    if(y<e-1&&mg[x][y+1]!='#'&&y1!=y+1)if(dfs(x,y+1,x,y))ans=min(ans,dfs(x,y+1,x,y));
    if(ans==1e9)u[x][y]=0;
    else u[x][y]=ans+1;
    return ans==1e9?0:ans+1;
}
int co[e][e][1000];
bool printg(int x,int y,int n){
    if(co[x][y][n]==-1)return 0;
    if(co[x][y][n]==1)return 1;
    if(mg[x][y]=='#'){
        co[x][y][n]=-1;
        return 0;
    }
    if(!n){
        if(!x&&!y){
            mg[x][y]='*';
            co[x][y][n]=1;
            return 1;
        }
        else{
            co[x][y][n]=-1;
            return 0;
        }
    }
    if(x&&printg(x-1,y,n-1)){
        mg[x][y]='*';
        co[x][y][n]=1;
        return 1;
    }
    if(x<e-1&&printg(x+1,y,n-1)){
        mg[x][y]='*';
        co[x][y][n]=1;
        return 1;
    }
    if(y&&printg(x,y-1,n-1)){
        mg[x][y]='*';
        co[x][y][n]=1;
        return 1;
    }
    if(y<e-1&&printg(x,y+1,n-1)){
        mg[x][y]='*';
        co[x][y][n]=1;
        return 1;
    }
    co[x][y][n]=-1;
    return 0;
}
struct pl{int x,y;}p;
int walk;
void print(){
    color(3);
    for(int i=0;i<=e+1;i++)putchar('#');
    puts("");
    for(int i=0;i<=e-1;i++){
        color(3);
        putchar('#'); 
        for(int j=0;j<=e-1;j++){
            color(2);
            putchar(mg1[i][j]);
            color(7);
        }
        color(3);
        putchar('#'); 
        puts("");
    }
    color(3);
    for(int i=0;i<=e+1;i++)putchar('#');
    puts("");
    color(7);
    cout<<"你的步数:"<<walk<<endl;
}
char press(){
    char c;
    c=getch();
//    cout<<c<<"\n";
    if(c=='w'||c=='W')return 'w';
    if(c=='s'||c=='S')return 's';
    if(c=='a'||c=='A')return 'a';
    if(c=='d'||c=='D')return 'd';
    if(c=='k'||c=='K')return 'k';
    if(c=='l'||c=='L')return 'l';
    if(c!=-32)return 'm';
    c=getch();
    if(c==72)return 'w';
    if(c==80)return 's';
    if(c==75)return 'a';
    if(c==77)return 'd';
}
void mgxyxg(){
	memset(co,0,sizeof(co));
    memset(use,0,sizeof(use)); 
    memset(mg,'#',sizeof(mg));
    walk=0;
    bu=0;
    p.x=e-1;
    p.y=e-1;
    cout<<"正在生成迷宫,请稍等一下...\n";
    grow:
        for(int i=0;i<=e-1;i++){
            for(int j=0;j<=e-1;j++){
                int l=rand(0,1);
                if(!l)mg[i][j]=' ';
                else mg[i][j]='#';
                //cout<<mg[i][j]<<" ";
            }
            //cout<<endl;
        }
    int b;
    do{
        memset(co,0,sizeof(co));
        memset(use,0,sizeof(use));
        memset(u,0,sizeof(u));
        mg[rand(0,e-1)][rand(0,e-1)]=' ';
        //cout<<endl<<endl<<endl;
        b=dfs(e-1,e-1,e,e-1);
    }while(!b);
    int xx,yy;
    for(int i=1;i<=e*e/100;i++){
        do{
            xx=rand(0,e-1);
            yy=rand(0,e-1);
            if((!xx&&!yy)||(xx==e-1&&yy==e-1)||mg[xx][yy]=='#'){
                continue;
            }
            memset(co,0,sizeof(co));
            memset(use,0,sizeof(use));
            memset(u,0,sizeof(u));
            mg[xx][yy]='#';
            //cout<<endl<<endl<<endl;
            b=dfs(e-1,e-1,e,e-1);
        }while(b);
        mg[xx][yy]=' ';
        memset(co,0,sizeof(co));
        memset(use,0,sizeof(use));
        memset(u,0,sizeof(u));
    }
//    for(int i=0;i<=e-1;i++){for(int j=0;j<=e-1;j++)cout<<mg[i][j]; cout<<endl;}
    b=dfs(e-1,e-1,e,e-1);
    for(int i=0;i<=e-1;i++)for(int j=0;j<=e-1;j++)if(mg[i][j]!='*')mg1[i][j]=mg[i][j];else mg1[i][j]=' ';
    if(!printg(e-1,e-1,b-1))goto grow;
    memset(u,0,sizeof(u));
    memset(use,0,sizeof(use));
    system("cls");
    print();
    pl p1;
    while(p.x||p.y){
//        print();
        gotoxy(p.y+2,p.x+2);
        color(4);
        cout<<'@';
        color(7);
        if(p.x!=p1.x||p.y!=p1.y){
            gotoxy(p1.y+2,p1.x+2);
            color(4);
            cout<<' ';
            color(7);
        }
        gotoxy(11,e+3);
        cout<<walk;
        p1=p;
        char c=press();
        if(c=='w'||c=='W'){
//        	cout<<p.x<<" "<<p.y<<"\n";
            if(p.x&&mg1[p.x-1][p.y]!='#'){
                walk++;
                p.x--;
            }
        }
        if(c=='s'||c=='S'){
            if(p.x<e-1&&mg1[p.x+1][p.y]!='#'){
                walk++;
                p.x++;
            }
        }
        if(c=='a'||c=='A'){
            if(p.y&&mg1[p.x][p.y-1]!='#'){
                walk++;
                p.y--;
            }
        }
        if(c=='d'||c=='D'){
            if(p.y<e-1&&mg1[p.x][p.y+1]!='#'){
                walk++;
                p.y++;
            }
        }
        if(c=='l'||c=='L'){
            system("cls");
            color(3);
            for(int i=0;i<=e+1;i++)putchar('#');
            puts("");
            for(int i=0;i<=e-1;i++){
                color(3);
                putchar('#');
                for(int j=0;j<=e-1;j++){
                    if(mg[i][j]=='#')color(2);
                    if(mg[i][j]=='*'){
                        color(4);
                        bu++;
                    }
                    cout<<mg[i][j];
                    color(7);
                }
                color(3);
                putchar('#');
                cout<<endl;
            }
            color(3);
            for(int i=0;i<=e+1;i++)putchar('#');
            puts("");
            color(7);
            cout<<"共需"<<bu-1<<"步\n";    
            return ;
        }
        if(c=='k'||c=='K'){
            memset(co,0,sizeof(co));
            memset(use,0,sizeof(use));
            memset(u,0,sizeof(u));
            for(int i=0;i<e;i++)for(int j=0;j<e;j++)mg[i][j]=mg1[i][j];
            printg(p.x,p.y,dfs(p.x,p.y,e,e-1)-1);
            system("cls");
            color(3);
            for(int i=0;i<=e+1;i++)putchar('#');
            puts("");
            for(int i=0;i<=e-1;i++){
                color(3);
                putchar('#');
                for(int j=0;j<=e-1;j++){
                    if(mg[i][j]=='#')color(2);
                    if(mg[i][j]=='*'){
                        color(4);
                        bu++;
                    }
                    cout<<mg[i][j];
                    color(7);
                }
                color(3);
                putchar('#');
                cout<<endl;
            }
            color(3);
            for(int i=0;i<=e+1;i++)putchar('#');
            puts("");
            color(7);
            cout<<"共需"<<bu-1<<"步\n";    
            return ;
        }
//        system("cls");
    }
    gotoxy(p.y,p.x);
    color(4);
    cout<<'@';
    color(7);
    if(p.x!=p1.x||p.y!=p1.y){
        gotoxy(p1.y,p1.x);
        color(4);
        cout<<' ';
        color(7);
    }
    for(int i=0;i<=e-1;i++)for(int j=0;j<=e-1;j++)if(mg[i][j]=='*')bu++;
    system("cls");
    cout<<"恭喜通关!\n你的步数:"<<walk<<"\n正解:"<<bu-1<<"\n";
}
#undef rand
struct sl{
	#define rep(i,l,r) for(int i=l;i<=r;i++)
	#define lep(i,l,r) for(int i=l;i>=r;i--)
	#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0X8000) ? 1:0)
	HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_FONT_INFO consoleCurrentFont;
	const int isshow=-1;
	int mp[100][100],num,canshow[100][100],now;
	int mp_vis[100][100];
	int isbj[100][100];
	bool tsbj[100][100];
	void print_num(int n) {
	    color(56);
	    if(n==1)cout<<"①";
	    if(n==2)cout<<"②";
	    if(n==3)cout<<"③";
	    if(n==4)cout<<"④";
	    if(n==5)cout<<"⑤";
	    if(n==6)cout<<"⑥";
	    if(n==7)cout<<"⑦";
	    if(n==8)cout<<"⑧";
	    color(7);
	}
	void print_map() {
	    cout<<"\n";
	    cout << "--------------------扫雷--------------------" << endl;
	    cout << "鼠标点击          左键翻开          右键标记" << endl;
	    cout << "--------------------------------------------" << endl;
	    cout<<"            ";
	    rep(i,1,9)cout<<i<<' ';
	    cout<<endl;
	    rep(i,1,9) {
	        cout<<"          ";
	        cout<<i<<' ';
	        rep(j,1,9) {
	//            cout<<mp[i][j]<<' ';
	            if(tsbj[i][j]) {
	                color(56);
	                cout<<"■";
	            } else if(isbj[i][j]) {
	                color(25);
	                if(isbj[i][j]==1) {
	                    cout<<"!";
	                } else {
	                    cout<<"?";
	                }
	            } else {
	                if(mp[i][j]==9) {
	                    color(25);
	                    cout<<"■";
	                } else {
	                    if(mp[i][j]==isshow) {
	                        color(56);
	                        cout<<"■";
	                    } else {
	                        if(canshow[i][j]) {
	                            print_num(mp[i][j]);
	                        } else {
	                            color(25);
	                            cout<<"■";
	                        }
	                    }
	                }
	            }
	
	            color(7);
	        }
	        cout<<endl;
	    }
	    cout<<"              剩余雷数:"<<num-now<<endl;
	}
	void print_gameover(int x,int y) {//游戏结束
	    system ("cls");
	    cout<<"\n";
	    cout << "--------------------扫雷--------------------" << endl;
	    cout << "鼠标点击          左键翻开          右键标记" << endl;
	    cout << "--------------------------------------------" << endl;
	    cout<<"            ";
	    rep(i,1,9)cout<<i<<' ';
	    cout<<endl;
	    rep(i,1,9) {
	        cout<<"          ";
	        cout<<i<<' ';
	        rep(j,1,9) {
	//            cout<<mp[i][j]<<' ';
	            if(i==x&&j==y)color(64),cout<<"﹡";
	            else if(mp[i][j]==9) {
	                color(12);
	                if(isbj[i][j]) {
	                    cout<<"×";
	                } else cout<<"﹡";
	            } else {
	                if(isbj[i][j]) {
	                    color(25);
	                    if(isbj[i][j]==1) {
	                        cout<<"!";
	                    } else {
	                        cout<<"?";
	                    }
	                } else {
	                    if(mp[i][j]==isshow) {
	                        color(56);
	                        cout<<"■";
	                    } else {
	                        if(canshow[i][j]) {
	                            print_num(mp[i][j]);
	                        } else {
	                            color(25);
	                            cout<<"■";
	                        }
	                    }
	                }
	            }
	
	            color(7);
	        }
	        cout<<endl;
	    }
	    Sleep(1000);
	    system("cls");
	    color(4);
	    printf(
	        "   _____          __  __ ______     ______      ________ _____  \n"
	        "  / ____|   /\\   |  \\/  |  ____|   / __ \\ \\    / /  ____|  __ \\\n"
	        " | |  __   /  \\  | \\  / | |__     | |  | \\ \\  / /| |__  | |__) |\n"
	        " | | |_ | / /\\ \\ | |\\/| |  __|    | |  | |\\ \\/ / |  __| |  _  / \n"
	        " | |__| |/ ____ \\| |  | | |____   | |__| | \\  /  | |____| | \\ \\ \n"
	        "  \\_____/_/    \\_\\_|  |_|______|   \\____/   \\/   |______|_|  \\_\\\n"
	    );
	    color(7);
	    return;
	}
	void print_win() {//你赢了
	    system ("cls");
	    color(10);
	    printf(
	        " __     ______  _    _   __          _______ _   _\n"
	        " \\ \\   / / __ \\| |  | |  \\ \\        / /_   _| \\ | |\n"
	        "  \\ \\_/ / |  | | |  | |   \\ \\  /\\  / /  | | |  \\| |\n"
	        "   \\   /| |  | | |  | |    \\ \\/  \\/ /   | | | . ` |\n"
	        "    | | | |__| | |__| |     \\  /\\  /   _| |_| |\\  |\n"
	        "    |_|  \\____/ \\____/       \\/  \\/   |_____|_| \\_|\n"
	    );
	    color(7);
	   return ;
	}
	const int fx[9]= {0,0,0,1,-1,-1,-1,1,1},fy[9]= {0,1,-1,0,0,1,-1,1,-1};
	void dfs(int x0,int y0) {
	    if(isbj[x0][y0])return;
	    if(x0>9||y0>9||x0<1||y0<1)return;
	    if(mp[x0][y0]==9)return;
	    canshow[x0][y0]=1;
	    if(mp[x0][y0]!=0)return;
	    mp[x0][y0]=isshow;
	    rep(i,1,8) {
	        dfs(x0+fx[i],y0+fy[i]);
	    }
	}
	bool check() {
	    int sum=0;
	    rep(i,1,9) {
	        rep(j,1,9) {
	            if(canshow[i][j]) {
	                sum++;
	            }
	        }
	    }
	    return sum==9*9-num;
	}
	int main() {
		memset(mp,0,sizeof(mp));
		memset(canshow,0,sizeof(canshow));
		memset(mp_vis,0,sizeof(mp_vis));
		memset(isbj,0,sizeof(isbj));
		memset(tsbj,0,sizeof(tsbj));
		num=now=0;
	    HWND h=GetForegroundWindow();
	    HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);
	    DWORD mode;
	    GetConsoleMode(hStdin,&mode);
	    mode&=~ENABLE_QUICK_EDIT_MODE;
	    SetConsoleMode(hStdin,mode);
		srand(time(NULL));
	    num=rand()%3+7;
	    rep(i,1,num) {
	        int x,y;
	        do {
	            x=rand()%9+1,y=rand()%9+1;
	        } while(mp_vis[x][y]==1);
	        mp_vis[x][y]=1;
	    }
	    rep(i,1,9) {
	        rep(j,1,9) {
	            rep(k,-1,1) {
	                rep(l,-1,1) {
	                    mp[i][j]+=mp_vis[i+k][j+l];
	                }
	            }
	            if(mp_vis[i][j])mp[i][j]=9;
	        }
	    }
	    while(1) {
	        memset(tsbj,0,sizeof(tsbj));
	        gotoxy(1,1);
	        print_map();
	        cout<<endl<<endl;
	
	//        作弊选项
	
	//        rep(i,1,9){
	//            rep(j,1,9){
	//                cout<<mp[i][j]<<' ';
	//                if(mp[i][j]>=0)cout<<' ';
	//            }
	//            cout<<endl;
	//        }
	        cout<<endl;
	        int y,x,opt=0;
	        while(1) {
	            if(KEY_DOWN(VK_LBUTTON)||KEY_DOWN(VK_RBUTTON))break;
	        }
	        if(KEY_DOWN(VK_LBUTTON)) {
	            POINT p;
	            GetCursorPos(&p);
	            ScreenToClient(h,&p);
	            GetCurrentConsoleFont(hOutput,FALSE,&consoleCurrentFont);
	            x=p.x/=consoleCurrentFont.dwFontSize.X;
	            y=p.y/=consoleCurrentFont.dwFontSize.Y;
	            x/=2;
	            y-=4;
	            Sleep(100);
	            int tmp=x;
	            x=y;
	            y=tmp-5;
	            opt=1;
	        } else if(KEY_DOWN(VK_RBUTTON)) {
	            POINT p;
	            GetCursorPos(&p);
	            ScreenToClient(h,&p);
	            GetCurrentConsoleFont(hOutput,FALSE,&consoleCurrentFont);
	            x=p.x/=consoleCurrentFont.dwFontSize.X;
	            y=p.y/=consoleCurrentFont.dwFontSize.Y;
	            x/=2;
	            y-=4;
	            Sleep(100);
	            int tmp=x;
	            x=y;
	            y=tmp-5;
	            opt=2;
	        }
	        if(opt==1) {
	            if(canshow[x][y]==1&&mp[x][y]!=9&&mp[x][y]!=0) {
	                int cntt=0;
	                rep(k,-1,1) {
	                    rep(l,-1,1) {
	                        if(x+k==0||x+k==10||y+l==0||y+l==10)continue;
	                        if(k==0&&l==0)continue;
	                        if(isbj[x+k][y+l]==1)cntt++;
	                        else if(!canshow[x+k][y+l])tsbj[x+k][y+l]=true;
	                    }
	                }
	                if(cntt==mp[x][y]) {
	                    rep(k,-1,1) {
	                        rep(l,-1,1) {
	                            if(k==0&&l==0)continue;
	                            if(x+k==0||x+k==10||y+l==0||y+l==10)continue;
	                            if(mp_vis[x+k][y+l]&&!isbj[x+k][y+l]) {
	                                print_gameover(x+k,y+l);
	                                return 0;
	                            }
	                        }
	                    }
	                    rep(k,-1,1) {
	                        rep(l,-1,1) {
	                            if(k==0&&l==0)continue;
	                            if(x+k==0||x+k==10||y+l==0||y+l==10)continue;
	                            dfs(x+k,y+l);
	                        }
	                    }
	                } else {
	                    gotoxy(1,1);
	                    print_map();
	                }
	            } else {
	                if(canshow[x][y])continue;
	                if(mp_vis[x][y]&&isbj[x][y]==0){
	                	print_gameover(x,y);
	                	return 0;
					}
	                dfs(x,y);
	            }
	
	        } else if(opt==2&&canshow[x][y]==0) {
	            if(x<10&&y<10&&x>0&&y>0) {
	                if(!isbj[x][y]) {
	                    now++;
	                    isbj[x][y]=1;
	                } else {
	                    if(isbj[x][y]==1) {
	                        now--;
	                        isbj[x][y]=2;
	                    } else {
	                        isbj[x][y]=0;
	                    }
	                    Sleep(100);
	                }
	            }
	
	        }
	        if(check()){
	        	print_win();
	        	return 0;
			}
	        Sleep(35);
	    }
	    return 0;
	}
};
void mgxyx(){
    system("cls");
    memset(co,0,sizeof(co));
    memset(use,0,sizeof(use)); 
    memset(mg,'#',sizeof(mg)); 
    mgxyxg();
    system("pause");
    system("cls");
}
void game(){
	cout<<"1、UNO\n2、随机迷宫\n3、扫雷\n";
	int cho=getch()-'0';
	system("cls");
	if(cho==1)UNO();
	else if(cho==2)mgxyx();
	else if(cho==3){cout<<"记得把快速编辑模式关掉\n";getch();system("cls");sl q;q.main();}
}
void _main(){
	system("cls");
	for(int i=0;i<_main_.size();i++){
		cout<<i+1<<"、"<<_main_[i]<<"\n";
	}
	int cho=getch()-'0';
	system("cls");
	if(cho==1)control();
	else if(cho==2)browser();
	else if(cho==3){
		freopen("tmp.txt","w",stdout);
		cout<<mn<<"\n"<<colour<<"\n";
		fclose(stdout);
		freopen("CON","w",stdout);
		exit(0);
	}
	else if(cho==4)game();
	else if(cho==5)fast();
	else if(cho==6)draw();
}
int main(){
   srand(time(0));
	hide();
	start();
	checkkey();
	init();
	while(1)_main();
}