chess_v2.cpp

来自「包括用VC开发的五子棋程序 以及VRML语言写的虚拟地理环境程序」· C++ 代码 · 共 54 行

CPP
54
字号
#include "Chess.h"
#include <iostream.h>
#include <stdlib.h>

int main()
{
	Chess yffch;
	int tempi,tempj,side;
	
	cout<<"Which side go first?"<<endl<<"1: Person	2:Machine"<<endl;
	cin>>side;
	if ( side==1 )
	{
		yffch.Output();
		yffch.PersonGo(tempi,tempj);
	
		while ( !yffch.Judge() )
		{
			yffch.ComputerGo();

			if ( yffch.Judge() )
				break;
			else
				yffch.PersonGo(tempi,tempj);			
		}
	}
	else
	{
		yffch.ComputerGoFirst();
		yffch.Output();
		
		yffch.PersonGo(tempi,tempj);
	
		while ( !yffch.Judge() )
		{
			yffch.ComputerGo();

			if ( yffch.Judge() )
				break;
			else
				yffch.PersonGo(tempi,tempj);			
		}
	}
	

	Step st1;
	st1=yffch.StepList.GetTail();
	if( st1.side==1 )
		cout<<endl<<endl<<endl<<"Person Win!"<<endl;
	else
		cout<<endl<<endl<<endl<<"Computer Win!"<<endl;

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?