PHP - Correccion ayuda!!

 
Vista:
sin imagen de perfil

Correccion ayuda!!

Publicado por Juan (2 intervenciones) el 18/06/2017 21:55:52
Hola , tengo problemas en el siguiente codigo . Uno de ellos es que se me reemplaza la ficha ; en esta parte pido la ficha de un jugador do {

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
printf("Jugador 1 diga las posiciones en la que quiera la ficha");
 
	scanf("%i",&x);
	scanf("%i",&y);
if (tablero[x][y] == 0 ){
	tablero[x-1][y-1] = 1 ;
	jugada = 1 ;
	jugadas = jugadas + 1 ;
}else{
	if (tablero[x][y]== 1 || tablero[x][y]==2){
 
	jugada = 0;
	}
}
}while(jugada == 0 ) ;

aca mando el codigo completo ; Desde ya muchas gracias ;

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
//tateti co
 
#include <stdio.h>
 
 
int main (){
 
	int tablero[3][3]= {0};
	int x , y , jugada  , jugadas = 0 , comprue;
	jugada = 0 ;
 
	do{
 
	    do {
 
		printf("Jugador 1 diga las posiciones en la que quiera la ficha");
 
			scanf("%i",&x);
			scanf("%i",&y);
		if (tablero[x][y] == 0 ){
			tablero[x-1][y-1] = 1 ;
			jugada = 1 ;
			jugadas = jugadas + 1 ;
		}else{
			if (tablero[x][y]== 1 || tablero[x][y]==2){
 
			jugada = 0;
	       	}
		}
	    }while(jugada == 0 ) ;
 
 
	    imprimir (tablero);
	    jugada = 0 ;
 
		comprue = comprobacion (tablero);
 
	    do {
 
		printf("Jugador 2 diga las posiciones en la que quiera la ficha");
		scanf("%i",&x);
		scanf("%i",&y);
		if (tablero[x][y] == 0 ){
			tablero[x-1][y-1] = 2 ;
			jugada = 1 ;
			jugadas = jugadas + 1 ;
		}else{
			if (tablero[x][y]== 1 || tablero[x][y]==2){
 
			jugada = 0;
	       	}
 
		}
	    }while(jugada == 0 );
 
	    jugada = 0 ;
	    imprimir (tablero);
	    comprue = comprobacion (tablero);
    }while (comprue !=  1 && jugadas < 9 );
printf("GANO EL JUGADOR %i ",comprue);
}
 
 
 
int comprobacion (int matriz[][3] ){
	int i , j , resultado ;
 
	for (i = 0 ; i < 3 ; i ++ ){
		for (j = 0 ; j < 3 ; j++){
			if (matriz[i][j] == 1 && matriz[i][j+1]== 1 && matriz[i][j+2] == 1 ){
				resultado = 1 ;
			}
			if (matriz[i][j] == 1 && matriz[i][j+1] == 1 && matriz[i][j+2]== 1 ){
				resultado = 1 ;
			}
			if (matriz[i][j] == 2 && matriz[i][j+1]== 2 && matriz[i][j+2] == 2 ){
				resultado = 2 ;
			}
			if (matriz[i][j] == 2 && matriz[i][j+1] == 2 && matriz[i][j+2]== 2 ){
				resultado = 2 ;
			}
		}
	}
	return (resultado);
}
 
imprimir (int ma[][3] ){
	int i , j ;
 
	for (i = 0 ; i < 3 ; i ++ ){
		for (j = 0 ; j < 3 ; j++){
 
			printf("%i ", ma[i][j]);
		}
		printf("\n");
	}
}
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