![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
04/03/2010, 04:12
|
| | Fecha de Ingreso: marzo-2010
Mensajes: 3
Antigüedad: 14 años, 11 meses Puntos: 0 | |
Respuesta: Juego Tres En Raya Cita:
Iniciado por Manu1982 HOLA TENGO QUE HACER EL JUEGO DEL TRES EN RAYA Y NO ME SALE, NO SE COMO CONTINUAR. AVER SI ALGUIEN ME AYUDA A TERMINARLO PLEASE.TENGO QUE USAR UNA FUNCION RECURSIVA PERO NO LLEVO MUCHO TIEMPO CON LA PROG Y SE ME DA BASTANTE MAL.TENGO QUE ENTREGARLO EL JUEVES PA CLASE...AYUDA!!
Código:
/*REALIZAR JUEGO TRES EN RAYA: JUGADOR CONTRA ORDENADOR*/
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
void tablero (int,int);
void jug_pc(void);
void jugador(void);
char matriz [3][3];
void main(void)
{
printf("BIENVENIDO AL TRES EN RAYA\n");
printf("--------------------------\n");
printf("Las posiciones empiezan en '0' y acaban en '2'\n\n");
printf("Jugador, introduce la posicion");
jugador();
}
void jugador(void)
{
int i,j;
printf("\n\n\n FILA : ");
scanf("%d",&i);
printf("\nCOLUMNA : ");
scanf("%d",&j);
if(i>3 || j>3)
{
printf("\n\nLo siento,esa coordenada no existe");
}
else
{
matriz[i][j]='X';
tablero(i,j);
getch();
}
clrscr();
flushall();
jug_pc();
getch();
}
void jug_pc(void)
{
int i,j;
for (i=0; i<3; i++)
{
for (j=0; j<3; j++)
{
if(matriz[i][j]!='X')
{
matriz[i][j]='O';
tablero(i,j);
jugador();
}
}
}
}
void tablero (int i,int j)
{
clrscr();
printf("\n\n 0 | 1 | 2 \n");
printf("-------------------\n");
printf(" 0 %c | %c | %c\n",matriz[0][0],matriz[0][1],matriz[0][2]);
printf("-------------------\n");
printf(" 1 %c | %c | %c\n",matriz[1][0],matriz[1][1],matriz[1][2]);
printf("-------------------\n");
printf(" 2 %c | %c | %c\n",matriz[2][0],matriz[2][1],matriz[2][2]);
return;
}
|