Dev - C++ - Alguien me ayuda, no entiendo porque no se imprime bien el tablero de ajedrez, Porfavor ayuda

 
Vista:
sin imagen de perfil
Val: 1
Ha aumentado su posición en 3 puestos en Dev - C++ (en relación al último mes)
Gráfica de Dev - C++

Alguien me ayuda, no entiendo porque no se imprime bien el tablero de ajedrez, Porfavor ayuda

Publicado por Alfonso (1 intervención) el 11/07/2018 05:54:58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <iostream>
#include <stdlib.h>
#include <windows.h>
 
using namespace std;
int main ()
{
	int a=0, xi,yi,xf,yf;
	bool turno=true;
	char ch;
	string tablero [19][19];
 
//Este par de for sirven para desplazar entre cada celda del tablero para llenarla ya sea con un espacio en blanco, marco del tablero, o fichas
	for(int y=0;y<19;y++)
	{
	    for(int x=0;x<19;x++)
	    {
	    	if((x==2 && y==16) || (x==16 && y==16))
			{
				tablero [x][y]='T'; //torre Blanca
			}
			else if ((x==2 && y==2) || (x==16 && y==2))
            {
                tablero [x][y]='t'; //torre Negra
            }
			else if ((x==4 && y==16) || (x==16 && y==16))
			{
				tablero [x][y]='C';
			}
			 else if ((x==4 && y==2) || (x==14 && y==2))
            {
                tablero [x][y]='c';
            }
			else if ((x==6 && y==16) || (x==12 && y==16))
			{
				tablero [x][y]='A';
			}
			 else if ((x==6 && y==2) || (x==12 && y==2))
            {
                tablero [x][y]='a';
            }
			else if ((y==4)&& (x%2==0))
			{
				tablero [x][y]='P';
			}
			 else if ((y==14)&& (x%2==0))
            {
                tablero [x][y]='p';
            }
			else if (x==8 && y==16)
			{
				tablero [x][y]='D';
			}
			 else if (x==8 && y==2)
            {
                tablero [x][y]='d';
            }
			else if(x==10 && y==16)
			{
				tablero [x][y]='R';
			}
			 else if (x==10 && y==2)
            {
                tablero [x][y]='r';
            }
			else if ((x==3)||(x==5)||(x==7)||(x==9)||(x==11)||(x==13)||(x==15))
			{
			    if((y==3)||(y==5)||(y==7)||(y==9)||(y==11)||(y==13)||(y==15))
            {
                tablero [x][y]= char(197);
            }
            }
            else if((x==2)||(x==4)||(x==6)||(x==8)||(x==10)||(x==12)||(x==14)||(x==16))
			{
			    if((y==1)||(y==3)||(y==5)||(y==7)||(y==9)||(y==11)||(y==13)||(y==15)||(y==17))
            {
                tablero [x][y]= char (196);
                }
			}
			else if((x==1)||(x==3)||(x==5)||(x==7)||(x==9)||(x==11)||(x==13)||(x==15)||(x==17))
			{
			    if((y==2)||(y==4)||(y==6)||(y==8)||(y==10)||(y==12)||(y==14)||(y==16))
            {
                tablero [x][y]= char (179);}
            }
            else if((x==17)&&(y==17))
            {
                tablero [x][y]= char(217);
            }
            else if((x==1)&&(y==1))
            {
                tablero [x][y]= char(218);
            }
            else if((x==17)&&(y==1))
            {
                tablero [x][y]= char(191);
            }
            else if ((x==1)&&(y==17))
            {
                tablero [x][y]= char(192);
            }
            	else if (x==1)
			{
			    if((y==3)||(y==5)||(y==7)||(y==9)||(y==11)||(y==13)||(y==15))
            {
				tablero [x][y]= char(195);
				}
			}
            else if(y==17)
			{
			    if((x==3)||(x==5)||(x==7)||(x==9)||(x==11)||(x==13)||(x==15))
            {
                tablero [x][y]= char(193);}
            }
            else if(y==1)
			{
			    if((x==3)||(x==5)||(x==7)||(x==9)||(x==11)||(x==13)||(x==15))
            {
                tablero [x][y]= char (194);}
            }
            else if(x==17)
			{
			    if((y==3)||(y==5)||(y==7)||(y==9)||(y==11)||(y==13)||(y==15))
            {
                tablero [x][y]= char(180);}
            }
            else
            {
                tablero [x][y]= " ";
            }
		}
 
	}
	while(a=-1)
	{
			system("cls");
	for (int y=0;y<19;y++)
	{
		for (int x=0;x<19;x++)
		{
			cout << tablero [x][y];
		}
		cout << endl;
    }
    if (turno == true)
    {
    	cout << "Turno del jugador 1 ingrese coordenadas iniciales (x/y) y las coordenadas de destino (x/y)" << endl;
    	cin >> xi >> ch >> yi;
    	cin >> xf >> ch >> yf;
    tablero [xf][yf]= tablero [xi][yi];
    tablero [xi][yi]=" ";
    turno = false;
	}
	system ("cls");
	for (int y=0;y<19;y++)
	{
		for (int x=0;x<19;x++)
		{
			cout << tablero [x][y];
		}
		cout << endl;
    }
	if (turno == false)
    {
    	cout << "Turno del jugador 2 ingrese coordenadas iniciales (x/y) y las coordenadas de destino (x/y)" << endl;
    	cin >> xi >> ch >> yi;
    	cin >> xf >> ch >> yf;
    tablero [xf][yf]= tablero [xi][yi];
    tablero [xi][yi]=" ";
    turno = true;
 
	}
 
    a++;
	}
	return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder