Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/05/2013, 22:09
Avatar de andre18agf
andre18agf
 
Fecha de Ingreso: mayo-2007
Mensajes: 13
Antigüedad: 17 años
Puntos: 0
No me corre juego tres rayas

#include <stdio.h>
char matriz [3][7];
int op=0, gana=0, emp=1, pla1=0, pla2=0, pjug=1, repe1; coordx=0, coordy=0;


void valores()
{
gana=0; emp=0; pjug=1;
int i, j;
for (i=0; i<=2; i++)
for (j=0; j<=6; j++)
matriz[i][j] =' ';
}
void casillas()
{
char oc;
if (pjug == 1)
oc='X';
else
oc='O';
switch (op) {
case 1 : if (matriz[0][0] != ' ') { repe1=1; break; } else {matriz[0][0]=oc; emp++; break;}
case 2 : if (matriz[0][1] != ' ') { repe1=1; break; } else {matriz[0][1]=oc; emp++; break;}
case 3 : if (matriz[0][2] != ' ') { repe1=1; break; } else {matriz[0][2]=oc; emp++; break;}
case 4 : if (matriz[0][3] != ' ') { repe1=1; break; } else {matriz[0][3]=oc; emp++; break;}
case 5 : if (matriz[0][4] != ' ') { repe1=1; break; } else {matriz[0][4]=oc; emp++; break;}
case 6 : if (matriz[0][5] != ' ') { repe1=1; break; } else {matriz[0][5]=oc; emp++; break;}
case 7 : if (matriz[0][6] != ' ') { repe1=1; break; } else {matriz[0][6]=oc; emp++; break;}
case 8 : if (matriz[0][7] != ' ') { repe1=1; break; } else {matriz[0][7]=oc; emp++; break;}
case 9 : if (matriz[1][0] != ' ') { repe1=1; break; } else {matriz[1][0]=oc; emp++; break;} }
}

void jug1()
{
printf("Jugador 1 - Introduce el numero: ");
scanf("\n&d","&d",&coordx, &coordy);
while (coordx>3 || coordy>7) {
printf("Opcion NO VALIDA, introduce una correcta: ");
scanf("\n&d","&d",&coordx, &coordy); }
casillas();
if (repe1 == 1) {
printf("Casilla ya elegida! ");
repe1=0;
jug1();}

pjug=2;
}

void jug2()
{
printf("Jugador 2 - Introduce el numero: ");
scanf("\n&d","&d",&coordx, &coordy);
while ( coordx>3 || coordy>7) {
printf("Opcion NO VALIDA, introduce una correcta: ");
scanf("\n&d","&d",&coordx, &coordy); }
casillas();
if (repe1 == 1) {

printf("Casilla ya elegida! ");
repe1=0;
jug1();}
pjug=1;
}

int opcion (){
int op=0;
If (coordx==0 && coordy==0)
op=0+1;
If (coordx==0 && coordy==1)
op=2;
If (coordx==0 && coordy==2)
op=3;
If (coordx==0 && coordy==3)
op=4;
If (coordx==0 && coordy==5)
op=5;
If (coordx==0 && coordy==6)
op=6;
If (coordx==0 && coordy==7)
op=7;
If (coordx==1 && coordy==0)
op=8;
return (op);
}
int cuadro(){

printf("\n\n 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | \n");
printf("---------------------------------------\n");
printf(" 1 | %c | %c | %c | %c | %c | %c | %c |\n",matriz[0][0],matriz[0][1],matriz[0][2],matriz[0][3],matriz[0][4],matriz[0][5],matriz[0][6],matriz[0][7]);
printf("---------------------------------------\n");
printf(" 2 | %c | %c | %c | %c | %c | %c | %c |\n",matriz[1][0],matriz[1][1],matriz[1][2],matriz[1][3],matriz[1][4],matriz[1][5],matriz[1][6],matriz[1][7]);
printf("---------------------------------------\n");
printf(" 3 | %c | %c | %c | %c | %c | %c | %c |\n",matriz[2][0],matriz[2][1],matriz[2][2],matriz[2][3],matriz[2][5],matriz[2][6],matriz[2][7],matriz[2][7]);
printf("---------------------------------------\n");

return;
}

main()
{
valores();
while (gana == 0)
{
cuadro();
switch(pjug)
{
case 1 : jug1(); break;
case 2 : jug2(); break;
}
}
}


Se me detiene en la funcion Opcion, nose que ocurre.