Oxo游戏问题继续 [英] Oxo game problem to continue

查看:79
本文介绍了Oxo游戏问题继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C ++编写此游戏程序,用于两个玩家的oxo游戏...我正处于检查玩家1输入的阶段...有人可以帮助我吗?

#include< iostream>
#include< math.h>
#include< stdlib.h>


使用名称空间std;

char arr1 [8] [8] = {};


void display();
void player1();

void main()
{
显示();
player1();
system("cls");
显示();
}


无效显示()
{
字符字母=``A'';
cout<< ("1 | 2 | 3 | 4 | 5 | 6 | 7 | 8")<< endl;
cout<< ("------------------------------------------------ -----------------)<< endl;
for(int y = 0; y< 8; y ++)
{

cout<<字母;


for(int x = 0; x< 8; x ++)

{

cout<< "|"<< arr1 [y] [x];


}
字母++;
cout<< endl;
cout<< "------------------------------------------------- ----------------<< endl;
cout<< endl;

}
}

void player1()
{
char p1move [30] = {''0''};
char p1sign [30] = {''0''};


布尔输入=假;

cout<< 请输入您的坐标移动..."<< endl;

{
cin>> p1move;

if(((p1move [0]>''0'')&&(p1move [0]<''9''))&&(((p1move [1]> ")&&(p1move [1]< I))||((p1move [1]<''))&&(p1move [1]<' 'i'')))))
{inputing = true;}

否则{cout<< (您的举动无效,请输入其他举动")<<恩德尔输入=假;}

}
while(输入== false);

输入=假;

cout<< 请输入您的标志..."<< endl;


{
cin>> p1sign;

if((p1sign [0] ==''x'')||(p1sign [0] ==''o''))
{inputing = true;}

否则{cout<< (您的举动无效,请输入其他符号")<<恩德尔输入=假;}

}
while(输入== false);

cout<< "ok";

int get,get1;

if(p1move [0] ==``1'')get = 0;
if(p1move [0] ==``2'')get = 1;
if(p1move [0] ==``3'')get = 2;
if(p1move [0] ==``4'')get = 3;
if(p1move [0] ==``5'')get = 4;
if(p1move [0] ==``6'')get = 5;
if(p1move [0] ==``7'')get = 6;
if(p1move [0] ==``8'')get = 7;

if(((p1move [1] ==``a''))||(p1move [1] ==``A''))get1 = 0;
if((p1move [1] ==``b'')||(p1move [1] ==``B''))get1 = 1;
if(((p1move [1] ==``c''))||(p1move [1] ==``C''))get1 = 2;
if((p1move [1] ==``d'')||(p1move [1] ==``D''))get1 = 3;
if(((p1move [1] ==``e''))||(p1move [1] ==``e''))get1 = 4;
if((p1move [1] ==``f'')||(p1move [1] ==``F''))get1 = 5;
if((p1move [1] ==``g'')||(p1move [1] ==``G''))get1 = 6;
if((p1move [1] ==``h'')||(p1move [1] ==``H''))get1 = 7;

arr1 [get1] [get] = p1sign [0];

}

I am writing this game program in c++ for a two player oxo game ...i am in the phase of checking the player 1 input...can someone help me ?

#include <iostream>
#include <math.h>
#include <stdlib.h>


using namespace std;

char arr1 [8][8] = {};


void display();
void player1();

void main ()
{
display ();
player1 ();
system("cls");
display ();
}


void display ()
{
char letter = ''A'';
cout << (" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8") <<endl;
cout << ("-----------------------------------------------------------------") <<endl;
for (int y =0; y<8; y++)
{

cout << letter;


for (int x =0; x<8; x++)

{

cout << " | "<<arr1 [y][x];


}
letter++;
cout << endl;
cout << "-----------------------------------------------------------------"<<endl;
cout << endl;

}
}

void player1()
{
char p1move [30]= {''0''};
char p1sign [30]= {''0''};


bool inputing = false;

cout << "please enter your co-ordinates Move..." <<endl;
do
{
cin >> p1move;

if ((( p1move[0] >''0'') && ( p1move[0] <''9'') ) && ( ( (p1move[1]> ''@'') && (p1move[1]<''I'') ) || ( (p1move[1]> ''<'') && (p1move[1]<''i'') ) ))
{inputing = true;}

else {cout << ("Your move is invalid, Please enter an other move")<< endl; inputing = false;}

}
while (inputing == false);

inputing = false;

cout << "please enter your sign..." <<endl;

do
{
cin >> p1sign;

if ( (p1sign[0] ==''x'') || (p1sign[0] ==''o'') )
{inputing = true;}

else {cout << ("Your move is invalid, Please enter another sign")<< endl; inputing = false;}

}
while (inputing == false);

cout << "ok";

int get, get1;

if (p1move[0] == ''1'') get = 0 ;
if (p1move[0] == ''2'') get = 1 ;
if (p1move[0] == ''3'') get = 2 ;
if (p1move[0] == ''4'') get = 3 ;
if (p1move[0] == ''5'') get = 4 ;
if (p1move[0] == ''6'') get = 5 ;
if (p1move[0] == ''7'') get = 6 ;
if (p1move[0] == ''8'') get = 7 ;

if ((p1move[1] == ''a'') || (p1move[1] == ''A'')) get1 = 0 ;
if ((p1move[1] == ''b'') || (p1move[1] == ''B'')) get1 = 1 ;
if ((p1move[1] == ''c'') || (p1move[1] == ''C'')) get1 = 2 ;
if ((p1move[1] == ''d'') || (p1move[1] == ''D'')) get1 = 3 ;
if ((p1move[1] == ''e'') || (p1move[1] == ''E'')) get1 = 4 ;
if ((p1move[1] == ''f'') || (p1move[1] == ''F'')) get1 = 5 ;
if ((p1move[1] == ''g'') || (p1move[1] == ''G'')) get1 = 6 ;
if ((p1move[1] == ''h'') || (p1move[1] == ''H'')) get1 = 7 ;

arr1 [get1][get]=p1sign[0];

}

推荐答案

什么是OXO?井字游戏?您需要对其进行编辑,以使问题更具体.我看到了您的代码,但我不打算运行它,并且需要告诉我您遇到了什么问题,代码的哪一部分不能按您期望的那样工作,或者您特别想知道该怎么做下一个.

如果这是家庭作业,请期望您的老师知道如何使用google.
What is OXO ? Tic tac toe ? You need to edit this to make your question specific. I see your code, but I do not plan to run it, and I need to be told what you are having trouble with, what part of the code doesn''t work as you expect OR what you specifically want to know how to do next.

If this is homework, expect that your teachers know how to use google.


这篇关于Oxo游戏问题继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆