跳到正文

休闲·娱乐

好玩的

zhaocs123456约 44 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年1月2日
篇幅
约 44 分钟

版本

  1. v1当前

MC

MC1

好东西

名字竞技场

MC官网

MC百科

创建MC成就

MC官网2

暴打蔡徐坤

线上MC

线上MC2

超多实用网址

超多好玩网址

俄罗斯轮盘赌

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
#include<cmath>
using namespace std;
int shi,dan,xu;
int cang[10];
char n;
string player1,player2;
int er1,er2;
int people=1;

void Color(int a){
    if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY|7);
	if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED|BACKGROUND_RED);
	if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED);
	if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY);
	if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_RED|BACKGROUND_INTENSITY|BACKGROUND_GREEN|BACKGROUND_RED);
	if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN|FOREGROUND_RED);
    if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
    if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);
}

void SetPos(int i, int j){
	COORD pos={i, j};
	HANDLE out=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(out, pos);
}

void init(){
	srand((unsigned)time(0));
	dan=rand()%8+1;
	shi=rand()%(dan-1)+1;
	xu=dan-shi;
}

void tianru(){
	int x=xu;
	int s=shi;
	for(int i=1;i<=dan;i++){
		int flag=rand()%2;
		if(flag==1&&s>0){
			s--;
			cang[i]=1;
			continue;
		}
		if(flag==0&&x>0){
			x--;
			cang[i]=0;
			continue;
		}
		if(x==0&&s>0){
			s--;
			cang[i]=1;
			continue;
		}
		if(s==0&&x>0){
			x--;
			cang[i]=0;
			continue;
		}
	}
	return ;
}

void zhanshi(){//展示弹药
	system("cls");
	cout<<"展示弹药如下"<<endl;
	cout<<"红色为实弹,灰色为虚弹。"<<endl;
	for(int j=1;j<=3;j++){
		for(int i=1;i<=dan;i++){
			if(i<=shi){
				cout<<" ";
				Color(2);
				cout<<"    ";
				Color(0);
				cout<<" ";
			}else{
				cout<<" ";
				Color(3);
				cout<<"    ";
				Color(0);
				cout<<" ";
			}
			cout<<" ";
		}
		cout<<endl;
	}
	for(int i=1;i<=dan;i++){
		Color(5);
		cout<<"_";
		Color(4);
		cout<<"____";
		Color(5);
		cout<<"_";
		Color(0);
		cout<<" ";
	}
	cout<<endl;
}

void gongju(){
	if(n=='d'){

	}else if(n=='q'){

	}else if(n=='x'){

	}else if(n=='s'){

	}else if(n=='f'){

	}else if(1){
	}
}
void gjx(){//播放攻击他人但是是虚弹的动画
	system("cls");
	printf(" _             _  \n");
	printf("|_|           |_| \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(500);
	system("cls");
	printf(" _             _  \n");
	printf("|_|    ====   |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(500);
	system("cls");
	printf(" _       咔!   _  \n");
	printf("|_|    ====   |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	SetPos(0,7);
	Sleep(300);
	printf("虚");
	Sleep(100);
	printf("弹");
	Sleep(100);
	printf("而");
	Sleep(100);
	printf("已\n");
	Sleep(1000);
}
void gjs(){//播放攻击他人但是是实弹的动画
	system("cls");
	printf(" _             _  \n");
	printf("|_|           |_| \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(500);
	system("cls");
	printf(" _             _  \n");
	printf("|_|    ====   |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(500);
	system("cls");
	printf(" _       嘭!   _  \n");
	printf("|_|    ====   |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	SetPos(0,1);
	Color(1);
	cout<<"|%|";
	Color(0);
	int ge=5;
	while(ge--){
		int x=rand()%4;
		int y=rand()%2;
		if(x==1&&y==1){
			ge++;
			continue;
		}
		SetPos(x,y);
		Color(2);
		cout<<" ";
		Color(0);
	}
	SetPos(0,7);
	Sleep(300);
	printf("实");
	Sleep(100);
	printf("弹");
	Sleep(100);
	printf("!");
	Sleep(100);
	printf("!\n");
	Sleep(1000);
}
void zsx(){//播放攻击自己但是是虚弹的动画
	system("cls");
	printf(" _             _  \n");
	printf("|_|           |_| \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(600);
	system("cls");
	printf(" _             _  \n");
	printf("|_|      ==== |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(600);
	system("cls");
	printf(" _       咔!   _  \n");
	printf("|_|      ==== |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	SetPos(0,7);
	Sleep(200);
	printf("虚");
	Sleep(100);
	printf("弹");
	Sleep(100);
	printf("而");
	Sleep(100);
	printf("已\n");
	Sleep(1000);
}
void zss(){//播放攻击自己但是是实弹的动画
	system("cls");
	printf(" _             _  \n");
	printf("|_|           |_| \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(500);
	system("cls");
	printf(" _             _  \n");
	printf("|_|      ==== |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	Sleep(500);
	system("cls");
	printf(" _       嘭!   _  \n");
	printf("|_|      ==== |_| \n");
	printf(" |       ||----|  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	printf(" |             |  \n");
	Color(6);
	SetPos(3,3);
	printf("___________");
	SetPos(3,4);
	printf("| |     | |");
	SetPos(3,5);
	printf("| |     | |");
	Color(0);
	SetPos(14,1);
	Color(1);
	cout<<"|%|";
	Color(0);
	int ge=5;
	while(ge--){
		int x=rand()%4;
		int y=rand()%2;
		x+=14;
		if(x==15&&y==1){
			ge++;
			continue;
		}
		SetPos(x,y);
		Color(2);
		cout<<" ";
		Color(0);
	}
	SetPos(0,7);
	Sleep(300);
	printf("实");
	Sleep(100);
	printf("弹");
	Sleep(100);
	printf("!");
	Sleep(100);
	printf("!\n");
	Sleep(1000);
}

void zxtwo(){
	while(1){
		init();
		tianru();
		zhanshi();
		Sleep(1000);
		printf("正在装填弹药中");
		int ti=dan;
		while(ti--){
			Sleep(200);
			cout<<".";
		}
		printf("\n装填完毕。");
		Sleep(1000);
		system("cls");
		for(int i=1;i<=dan;i++){
			system("cls");
			cout<<player1<<":";
			for(int j=1;j<=6;j++){
				if(j<=er1){
					Color(2);
					cout<<"_";
					Color(0);
				}else{
					Color(7);
					cout<<"_";
					Color(0);
				}
			}
			cout<<endl;
			cout<<player2<<":";
			for(int j=1;j<=6;j++){
				if(j<=er2){
					Color(2);
					cout<<"_";
					Color(0);
				}else{
					Color(7);
					cout<<"_";
					Color(0);
				}
			}
			cout<<endl;
			if(people==1){
				cout<<"这是"<<player1<<"的回合,请攻击: \n";
				cout<<"1."<<player1<<";\n";
				cout<<"2."<<player2<<";\n";
			}else if(people==2){
				cout<<"这是"<<player2<<"的回合,请攻击: \n";
				cout<<"1."<<player2<<";\n";
				cout<<"2."<<player1<<";\n";
			}

			cin>>n;

			if(n=='1'){
				if(cang[i]==1){
					zss();
					Sleep(1000);
					printf("你打中了自己,扣一滴血\n");
					if(people==1){
						er1--;
					}else if(people==2){
						er2--;
					}
				}else if(cang[i]==0){
					zsx();
				}
			}

			else if(n=='2'){
				if(cang[i]==1){
					gjs();
					if(people==1){
						er2--;
					}else if(people==2){
						er1--;
					}

				}else if(cang[i]==0){
					gjx();
				}

				if(people==1){
					people=2;
				}else if(people==2){
					people=1;
				}
			}

			Sleep(500);
			if(er1==0||er2==0){
				return ;
			}
		}
		if(er1==0||er2==0){
			return ;
		}
		if(er1!=0&&er2!=0){
			printf("子弹打完了,重新填弹\n");
			Sleep(1000);
		}

	}
	return ;
}

int main(){
	Color(0);
	printf("欢迎来到俄罗斯轮盘赌。\n");
	printf("请输入你的名字,player1:\n");
	cin>>player1;
	printf("请输入你的名字,player2:\n");
	cin>>player2;
	er1=6;
	er2=6;
	zxtwo();
	if(er1==0){
		cout<<player1<<"死了,他化作了地底的亡魂。"<<endl;
		cout<<player2<<"赢了,他获得了50000000¥。"<<endl;
	}else if(er2==0){
		cout<<player2<<"死了,他化作了地底的亡魂。"<<endl;
		cout<<player1<<"赢了,他获得了50000000 $。"<<endl;
    }
    return 0;
}

星战

C++
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int hp=1000000000,atk=2000000000,dfs=100000000,hpm=10000100,ex=100000,exm=
1,rmb=100000,sld=100000,ylb=200000,wu,zhu;
string name;
string gname[6]={"星空小兵","帝国冲锋队","一级战士","行星械师","帝国战舰","黑武士"};
int ghp[6]={50,160,300,500,2000,3000},gatk[6]={10,20,50,100,200,500},gdfs[6]={0,5,20,30,80,200},grmb[6]={20,50,200,500,2000,5000},gex[6]={20,50,100,200,500,1000};
int watk[8]={10,40,100,300,5,25,60,180},wrmb[8]={50,200,500,1500,40,160,400,1200};
int a,b,c,d,i,j;
bool zhuang[10]={0};
void shop();
void Boos();
void dazhang(int);
void level_up();
void die();
void chakan()
{
	cout<<"生命值"<<hp<<"/"<<hpm<<endl;
	cout<<"攻击力"<<atk<<endl;
	cout<<"防御力"<<dfs<<endl;
	cout<<"经验"<<ex<<"/"<<exm<<endl;
	cout<<"星币"<<rmb<<endl;
	cout<<"手榴弹数"<<sld<<endl;
	cout<<"医疗包数"<<ylb<<endl<<endl;
	Sleep(4000);
}
void zhuangbei()
{
	cout<<"选择要装备的武器或防具:"<<endl;
	cout<<"1 匕首"<<endl;
	cout<<"2 激光剑"<<endl;
	cout<<"3 星空粒子炮"<<endl;
	cout<<"4 死亡射线发射器"<<endl;
	cout<<"5 战斗盔甲"<<endl;
	cout<<"6 武士制服"<<endl;
	cout<<"7 力场保护罩"<<endl;
	cout<<"8 神灵战衣"<<endl<<endl;
	cin>>b;
	if(b>=1&&b<=4)
	{
		if(zhuang[b-1]==0){cout<<"你没有!!!"<<endl<<endl;}
		else
		{
			atk-=wu;
			atk+=watk[b-1];
			wu=watk[b-1];
			cout<<"装备成功!!!"<<endl<<endl;
		}
	}
	if(b>=5&&b<=8)
	{
		if(zhuang[b-1]==0){cout<<"你没有!!!"<<endl<<endl;}
		else
		{
			dfs-=zhu;
			dfs+=watk[b-1];
			zhu=watk[b-1];
			cout<<"装备成功!!!"<<endl<<endl;
		}
	}
}
void story1()
{
	cout<<"很久很久以前,在一个遥远的星系,一场正义与邪恶的战争爆发了。"<<endl<<endl;
	Sleep(1000);
	cout<<"各式各样的太空船在星球间来回穿梭,五彩缤纷的能量光束在不停的闪耀。"<<endl<<endl;
	Sleep(1000);
	cout<<"武士们挥舞着威力无比的激光剑相互厮杀,时不时把对手砍成两半。"<<endl<<endl;
	Sleep(1000);
	cout<<"作为一名正义的勇者,你必须帮助反叛军打败邪恶的帝国"<<endl<<endl;
	Sleep(1000);
	cout<<"拿起你的武器,去宇宙中战斗吧!"<<endl<<endl;
	Sleep(1000);
	cout<<"输入你的名字:";
	Sleep(1000);
}
void story2()
{
	cout<<"经过不懈的努力,我们的勇者终于打败了黑武士"<<endl;
	Sleep(1000);
	cout<<"群龙无首的帝国军队很快被打败。"<<endl;
	Sleep(1000);
	cout<<"宇宙终于从帝国的统治中解脱出来。"<<endl;
	Sleep(1000);
	cout<<"但是,故事并没有结束。"<<endl;
	Sleep(1000);
	cout<<"由于意见不合,反叛军内部分成了两派,开始互相攻击"<<endl;
	Sleep(1000);
	cout<<"敬请期待第二部:《星球大战:内战》"<<endl;
	Sleep(1000);
}
void yidong()
{
	cout<<"要去哪里?"<<endl;
	cout<<"1 星际商店 2 星空战场 3 帝国内部 4 太空决斗场 5 黑暗行星 6 战舰港湾 7 帝国首都"<<endl<<endl;
	cin>>b;
	if(b==1) shop();
	if(b>=2&&b<=6)dazhang(b-2);
	if(b==7)Boos();
}
void shop()
{
	cout<<"要买什么?"<<endl;
	cout<<"1 匕首 50星币"<<endl;
	cout<<"2 激光剑 200星币"<<endl;
	cout<<"3 星空粒子炮 500星币"<<endl;
	cout<<"4 死亡射线发射器 1500星币"<<endl;
	cout<<"5 战斗盔甲 40星币"<<endl;
	cout<<"6 武士制服 160星币"<<endl;
	cout<<"7 力场保护罩 400星币"<<endl;
	cout<<"8 神灵战衣 1200星币"<<endl;
	cout<<"9 星际手榴弹 25星币"<<endl;
	cout<<"10 太空医疗包 25星币"<<endl;
	cin>>c;
	if(c>=1&&c<=8)
	{
		if(rmb>=wrmb[c-1])
		{
			cout<<"已购买"<<endl<<endl;
			zhuang[c]=true;
			rmb-=wrmb[c-1];
		}
		else cout<<"钱不够!!!"<<endl<<endl;
	}
	if(c==9){if(rmb>=25){rmb-=25;cout<<"已购买"<<endl<<endl;sld++;}else cout<<"钱不够!!!"<<endl<<endl;}
	if(c==10){if(rmb>=25){rmb-=25;cout<<"已购买"<<endl<<endl;ylb++;}else cout<<"钱不够!!!"<<endl<<endl;}
}
void dazhang(int n)
{
	int dhp=ghp[n];
	printf("%s向你发动了攻击!!!",&gname[n]);
	while(hp>0&&dhp>0)
	{
		cout<<"该怎么办?"<<endl;
		cout<<"1 攻击 2 扔手榴弹 3 用医疗包 4 逃跑 5 查看状况"<<endl<<endl;
		cin>>d;
		if(d==1)
		{
			cout<<"你对敌人造成了"<<atk-gdfs[n]<<"点伤害"<<endl;
			cout<<"敌人对你造成了"<<gatk[n]-dfs<<"点伤害"<<endl<<endl;
			dhp-=(atk-gdfs[n]);
			hp-=(gatk[n]-dfs);
		}
		if(d==2)
		{
			cout<<"轰!你对敌人造成了100点伤害"<<endl;
			cout<<"敌人对你造成了"<<gatk[n]-dfs<<"点伤害"<<endl<<endl;
			dhp-=100;
			hp-=(gatk[n]-dfs);
		}
		if(d==3)
		{
			cout<<"你回了100点生命值"<<endl<<endl;
			hp+=100;
		}
		if(d==4)
		{
			cout<<"逃跑成功!"<<endl<<endl;
			break;
		}
		if(d==5)
		chakan();
		if(hp<=0){die();return;}
		if(dhp<=0)
		{
			printf("恭喜你战胜%s!!!获得经验%d星币%d/n/n",&gname[n],gex[n],grmb[n]);
			if(ex>=exm)level_up();
			return;
		}
	}
}
void die()
{
	cout<<name<<"战死!!!"<<endl<<endl;
	Sleep(1000);
	cout<<"游戏结束!!!";
	return;
}
void level_up()
{
	ex-=exm;
	exm+=10;
	hpm+=25;
	hp=hpm;
	atk+=5;
	dfs+=3;
	cout<<name<<"升级!!!攻击力+5,防御力+3,生命上限+20"<<endl<<endl;
}
void Boos()
{
	int dhp=ghp[6];
	printf("%s向你发动了攻击!!!",&gname[6]);
	while(hp>0&&dhp>0)
	{
		cout<<"该怎么办?"<<endl;
		cout<<"1 攻击 2 扔手榴弹 3 用医疗包 4 逃跑 5 查看状况"<<endl<<endl;
		cin>>d;
		if(d==1)
		{
			cout<<"你对敌人造成了"<<atk-gdfs[6]<<"点伤害"<<endl;
			cout<<"敌人对你造成了"<<gatk[6]-dfs<<"点伤害"<<endl<<endl;
			dhp-=(atk-gdfs[6]);
			hp-=(gatk[6]-dfs);
		}
		if(d==2)
		{
			cout<<"轰!你对敌人造成了100点伤害"<<endl;
			cout<<"敌人对你造成了"<<gatk[6]-dfs<<"点伤害"<<endl<<endl;
			dhp-=100;
			hp-=(gatk[6]-dfs);
		}
		if(d==3)
		{
			cout<<"你回了100点生命值"<<endl<<endl;
			hp+=100;
		}
		if(d==4)
		{
			cout<<"逃跑成功!"<<endl<<endl;
			break;
		}
		if(d==5) chakan();
		if(hp<=0){die();return;}
		if(dhp<=0)
		{
			printf("恭喜你战胜%s!!!获得经验%d星币%d/n/n",&gname[6],gex[6],grmb[6]);
			if(ex>=exm)level_up();
			story2();
			ghp[6]=0;
			return;
		}
	}
}
int main()
{
	story1();
	cin>>name;
	cout<<endl;
	while(hp>0&&ghp[5]>0)
	{
		cout<<"要做什么?"<<endl;
		Sleep(500);
		cout<<"1 移动 2 装备 3 查看状况 4 结束游戏"<<endl<<endl;
		cin>>a;
		if(a==1)yidong();
		if(a==2)zhuangbei();
		if(a==3)chakan();
		if(a==4)
		{
			cout<<"游戏结束!!";
			return 0;
		}
	}
	return 0;

五子棋

C++
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define MAXIMUS 15 //¶¨ÒåÆåÅÌ´óС
int p[MAXIMUS][MAXIMUS];//´æ´¢¶Ô¾ÖÐÅÏ¢
char buff[MAXIMUS*2+1][MAXIMUS*4+3];//Êä³ö»º³åÆ÷
int Cx,Cy;//µ±Ç°¹â±êλÖÃ
int Now;//µ±Ç°×ß×ÓµÄÍæ¼Ò£¬1´ú±íºÚ£¬2´ú±í°×
int wl,wp;//µ±Ç°Ð´È뻺³åÆ÷µÄÁÐÊýºÍÐÐÊýλÖÃ
char* showText;//ÔÚÆåÅÌÖÐÑëÏÔʾµÄÎÄ×ÖÐÅÏ¢
int count;//»ØºÏÊý
char* Copy(char* strDest,const char* strSrc)//Ð޸ĹýµÄ×Ö·û´®¸´Öƺ¯Êý£¬»áºöÂÔÄ©¶ËµÄ\0
{
	char* strDestCopy = strDest;
	while (*strSrc!='\0')
	{
		*strDest++=*strSrc++;
	}
	return strDestCopy;
}
void Initialize()//³õʼ»¯Ò»¸ö¶Ô¾Öº¯Êý
{
	int i,j;//Ñ­»·±äÁ¿
	showText="";//ÖØÖÃÏÔʾÐÅÏ¢
	count=0;//»ØºÏÊý¹éÁã
	for(i=0;i<MAXIMUS;i++)//ÖØÖöԾÖÊý¾Ý
	{
		for(j=0;j<MAXIMUS;j++)
		{
			p[i][j]=0;
		}
	}
	Cx=Cy=MAXIMUS/2;//ÖØÖùâ±êµ½ÖÐÑë
	Now=1;//ÖØÖõ±Ç°ÎªºÚ·½
}
char* getStyle(int i,int j)//»ñµÃÆåÅÌÖÐÖ¸¶¨×ø±ê½»µãλÖõÄ×Ö·û£¬Í¨¹ýÖÆ±í·ûÆ´³ÉÆåÅÌ
{
	if(p[i][j]==1)//1ΪºÚ×Ó
		return "¡ñ";
	else if(p[i][j]==2)//2Ϊ°××Ó
		return "¡ð";
	else if(i==0&&j==0)//ÒÔÏÂΪ±ßÔµÆåÅÌÑùʽ
		return "©³";
	else if(i==MAXIMUS-1&&j==0)
		return "©·";
	else if(i==MAXIMUS-1&&j==MAXIMUS-1)
		return "©¿";
	else if(i==0&&j==MAXIMUS-1)
		return "©»";
	else if(i==0)
		return "©Ä";
	else if(i==MAXIMUS-1)
		return "©Ì";
	else if(j==0)
		return "©Ó";
	else if(j==MAXIMUS-1)
		return "©Û";
		return "©à";//ÖмäµÄ¿Õλ
}
char* getCurse(int i,int j){//»ñµÃÖ¸¶¨×ø±ê½»µãλÖÃ×óÉϸñµÄÑùʽ£¬Í¨¹ýÖÆ±í·ûÀ´Ä£Äâ¹â±êµÄÏÔʾ
	if(i==Cx){
		if(j==Cy)
			return "©³";
		else if (j==Cy+1)
			return "©»";
	}
	else if(i==Cx+1)
	{
		if(j==Cy)
			return "©·";
		else if (j==Cy+1)
			return "©¿";
	}
	return "¡¡";//Èç¹û²»ÔÚ¹â±ê¸½½üÔòΪ¿Õ
}
void write(char* c)//Ïò»º³åÆ÷дÈë×Ö·û´®
{
	Copy(buff[wl]+wp,c);
	wp+=strlen(c);
}
void ln()//»º³åÆ÷дÈëλÖÃÌáÐÐ
{
	wl+=1;
	wp=0;
}
void Display()//½«»º³åÆ÷ÄÚÈÝÊä³öµ½ÆÁÄ»
{
	int i,l=strlen(showText);//Ñ­»·±äÁ¿£¬ÖмäÎÄ×ÖÐÅÏ¢µÄ³¤¶È
	int Offset=MAXIMUS*2+2-l/2;//Ëã³öÖмäÎÄ×ÖÐÅÏ¢¾ÓÖÐÏÔʾËùÔڵĺá×ø±êλÖÃ
	if(Offset%2==1)//Èç¹ûλÖÃÎªÆæÊý£¬ÔòÒÆ¶¯µ½Å¼Êý£¬±ÜÃâ»ìÂÒ
	{
		Offset--;
	}
	Copy(buff[MAXIMUS]+Offset,showText);//½²ÖмäÎÄ×ÖÐÅÏ¢¸´ÖƵ½»º³åÆ÷
	if(l%2==1)//Èç¹ûÖмäÎÄ×Ö³¤¶ÈΪ°ë½ÇÆæÊý£¬Ôò²¹ÉϿոñ£¬±ÜÃâ»ìÂÒ
	{
		*(buff[MAXIMUS]+Offset+l)=0x20;
	}
	system("cls");//ÇåÀíÆÁÄ»£¬×¼±¸Ð´Èë
	for(i=0;i<MAXIMUS*2+1;i++){//Ñ­»·Ð´ÈëÿһÐÐ
		printf("%s",buff[i]);
		if(i<MAXIMUS*2)//дÈëÍêÿһÐÐÐèÒª»»ÐÐ
			printf("\n");
	}
}
void Print()//½«Õû¸öÆåÅÌËã³ö²¢´¢´æµ½»º³åÆ÷£¬È»ºóµ÷ÓÃDisplayº¯ÊýÏÔʾ³öÀ´
{
	int i,j;//Ñ­»·±äÁ¿
	wl=0;
	wp=0;
	for(j=0;j<=MAXIMUS;j++)//дÈë³ö½»µã×óÉϽǵÄ×Ö·û£¬ÒòΪÐèÒª´òÓ¡ÆåÅÌÓÒϽǣ¬ËùÒÔºÜÒÔºá×ݸ÷¶àÒ»´ÎÑ­»·
	{
		for(i=0;i<=MAXIMUS;i++)
		{
			write(getCurse(i,j));//дÈë×óÉϽÇ×Ö·û
			if(j==0||j==MAXIMUS)//Èç¹ûÊÇÆåÉÏÏÂÅ̱ßÔµÔòûÓÐÁ¬½ÓµÄÊúÏߣ¬ÓÿոñÌî³äλÖÃ
			{
				if(i!=MAXIMUS)
				write("¡¡");
			}
			else//Èç¹ûÔÚÆåÅÌÖмäÔòÓÃÊúÏ߳нÓÉÏÏÂ
			{
				if(i==0||i==MAXIMUS-1)//×óÓÒ±ßÔµµÄÊúÏ߸ü´Ö
				write("©§");
				else if(i!=MAXIMUS)//ÖмäµÄÊúÏß
				write("©¦");
			}
		}
		if(j==MAXIMUS)//Èç¹ûÊÇ×îºóÒ»´ÎÑ­»·£¬ÔòÖ»ÐèÒª´¦Àí±ß²à×Ö·û£¬½»µãÒªÉÙÒ»ÅÅ
		{
			break;
		}
		ln();//ÌáÐпªÊ¼´òÓ¡½»µãÄÚÈÝ
		write("¡¡");//ÓÿÕλ²¹ÆëλÖÃ
		for(i=0;i<MAXIMUS;i++)//°´ºá×ø±êÑ­»·Õý³£µÄ´ÎÊý
		{
			write(getStyle(i,j));//дÈë½»µã×Ö·û
			if(i!=MAXIMUS-1)//Èç¹û²»ÔÚ×îÓÒ²àÔò²¹³äÒ»¸öºáÏ߳нÓ×óÓÒ
			{
				if(j==0||j==MAXIMUS-1)
				{
					write("©¥");//ÉÏϱßÔµµÄºáÏ߸ü´Ö
				}
				else
				{
					write("¡ª");//ÖмäµÄºáÏß
				}
			}
		}
		ln();//дÍêÒ»ÐкóÌáÐÐ
	}
	Display();//½«»º³åÆ÷ÄÚÈÝÊä³öµ½ÆÁÄ»
}
int Put(){//ÔÚµ±Ç°¹â±êλÖÃ×ß×Ó£¬Èç¹û·Ç¿Õ£¬Ôò·µ»Ø0±íʾʧ°Ü
	if(p[Cx][Cy]==0)
	{
		p[Cx][Cy]=Now;//¸Ä±ä¸ÃλÖÃÊý¾Ý
		return 1;//·µ»Ø1±íʾ³É¹¦
	}
	else
	{
		return 0;
	}
}
int Check()//ʤ¸º¼ì²é£¬¼´Åжϵ±Ç°×ß×ÓλÖÃÓÐûÓÐÔì³ÉÎåÁ¬ÖéµÄÇé¿ö
{
	int w=1,x=1,y=1,z=1,i;//ÀۼƺáÊúÕýб·´Ð°Ëĸö·½ÏòµÄÁ¬ÐøÏàͬÆå×ÓÊýÄ¿
	for(i=1;i<5;i++)if(Cy+i<MAXIMUS&&p[Cx][Cy+i]==Now)w++;else break;//Ïòϼì²é
	for(i=1;i<5;i++)if(Cy-i>0&&p[Cx][Cy-i]==Now)w++;else break;//ÏòÉϼì²é
	if(w>=5)return Now;//Èô¹û´ïµ½5¸öÔòÅжϵ±Ç°×ß×ÓÍæ¼ÒΪӮ¼Ò
	for(i=1;i<5;i++)if(Cx+i<MAXIMUS&&p[Cx+i][Cy]==Now)x++;else break;//ÏòÓÒ¼ì²é
	for(i=1;i<5;i++)if(Cx-i>0&&p[Cx-i][Cy]==Now)x++;else break;//Ïò×ó¼ì²é
	if(x>=5)return Now;//Èô¹û´ïµ½5¸öÔòÅжϵ±Ç°×ß×ÓÍæ¼ÒΪӮ¼Ò
	for(i=1;i<5;i++)if(Cx+i<MAXIMUS&&Cy+i<MAXIMUS&&p[Cx+i][Cy+i]==Now)y++;else break;//ÏòÓÒϼì²é
	for(i=1;i<5;i++)if(Cx-i>0&&Cy-i>0&&p[Cx-i][Cy-i]==Now)y++;else break;//Ïò×óÉϼì²é
	if(y>=5)return Now;//Èô¹û´ïµ½5¸öÔòÅжϵ±Ç°×ß×ÓÍæ¼ÒΪӮ¼Ò
	for(i=1;i<5;i++)if(Cx+i<MAXIMUS&&Cy-i>0&&p[Cx+i][Cy-i]==Now)z++;else break;//ÏòÓÒÉϼì²é
	for(i=1;i<5;i++)if(Cx-i>0&&Cy+i<MAXIMUS&&p[Cx-i][Cy+i]==Now)z++;else break;//Ïò×óϼì²é
	if(z>=5)return Now;//Èô¹û´ïµ½5¸öÔòÅжϵ±Ç°×ß×ÓÍæ¼ÒΪӮ¼Ò
	return 0;//ÈôûÓмì²éµ½ÎåÁ¬Ö飬Ôò·µ»Ø0±íʾ»¹Ã»ÓÐÍæ¼Ò´ï³ÉʤÀû
}
int RunGame()//½øÐÐÕû¸ö¶Ô¾Ö£¬·µ»ØÓ®¼ÒÐÅÏ¢(ËäÈ»ÓÐÓÃÉÏ)
{
	int input;//ÊäÈë±äÁ¿
	int victor;//Ó®¼ÒÐÅÏ¢
	Initialize();//³õʼ»¯¶Ô¾Ö
	while(1){//¿ªÊ¼ÎÞÏ޻غϵÄËÀÑ­»·£¬Ö±µ½³öÏÖʤÀûÌø³ö
	Print();//´òÓ¡ÆåÅÌ
	input=getch();//µÈ´ý¼üÅ̰´ÏÂÒ»¸ö×Ö·û
	if(input==27)//Èç¹ûÊÇESCÔòÍ˳ö³ÌÐò
	{
		exit(0);
	}
	else if(input==0x20)//Èç¹ûÊǿոñÔò¿ªÊ¼×ß×Ó
	{
		if(Put())//Èç¹û×ß×ӳɹ¦ÔòÅжÏʤ¸º
		{
			victor=Check();
			Now=3-Now;//ÂÖ»»µ±Ç°×ß×ÓÍæ¼Ò
			count++;
			if(victor==1)//Èç¹ûºÚ·½´ïµ½Ê¤Àû£¬ÏÔʾÌáʾÎÄ×Ö²¢µÈ´ýÒ»´Î°´¼ü£¬·µ»ØÊ¤ÀûÐÅÏ¢
			{
				showText="ºÚ·½»ñµÃÁËʤÀû£¡";
				Print();
				if(getch()==0xE0)
				{
					getch();
				}
				return Now;
			}
			else if(victor==2)//Èç¹û°×·½´ïµ½Ê¤Àû£¬ÏÔʾÌáʾÎÄ×Ö²¢µÈ´ýÒ»´Î°´¼ü£¬·µ»ØÊ¤ÀûÐÅÏ¢
			{
				showText="°×·½»ñµÃÁËʤÀû£¡";
				Display();
				if(getch()==0xE0)
				{
					getch();
				}
				return Now;
			}else if(count==MAXIMUS*MAXIMUS)//Èç¹û»ØºÏÊý´ïµ½ÁËÆåÅÌ×ÜÁ¿£¬¼´ÆåÅ̳äÂú£¬¼´ÎªÆ½¾Ö
			{
				showText="ƽ¾Ö£¡";
				Display();
				if(getch()==0xE0)
				{
					getch();
				}
				return 0;
			}
		}
	}
	else if(input==0xE0)//Èç¹û°´ÏµÄÊÇ·½Ïò¼ü£¬»áÌî³äÁ½´ÎÊäÈ룬µÚÒ»´ÎΪ0xE0±íʾ°´ÏµÄÊÇ¿ØÖƼü
	{
		input=getch();//»ñµÃµÚ¶þ´ÎÊäÈëÐÅÏ¢
		switch(input)//ÅжϷ½Ïò¼ü·½Ïò²¢Òƶ¯¹â±êλÖÃ
		{
			case 0x4B://
				Cx--;
				break;
			case 0x48:
				Cy--;
				break;
			case 0x4D:
				Cx++;
				break;
			case 0x50:
				Cy++;
				break;
		}
		if(Cx<0)Cx=MAXIMUS-1;//Èç¹û¹â±êλÖÃÔ½½çÔòÒÆ¶¯µ½¶Ô²à
		if(Cy<0)Cy=MAXIMUS-1;
		if(Cx>MAXIMUS-1)Cx=0;
		if(Cy>MAXIMUS-1)Cy=0;
	}
}
}
int main()//Ö÷º¯Êý
{
	system("mode con cols=63 lines=32");
	system("color A1");//ÉèÖÃÑÕÉ«
	while(1){//Ñ­»·Ö´ÐÐÓÎÏ·
		RunGame();
	}
	return 0;
}
原文