|
Mostrar Mensajes
|
Páginas: 1 2 3 [4]
|
31
|
Programación / Programación C/C++ / Ayuda
|
en: 6 Junio 2013, 21:18 pm
|
leosansan como estas? Eh estado tratando de solucionar los problemas que me marcaste, mas precisamente que me imprima hacia arriba las jugadas pero no lo eh lo grado me podrias decir en que estoy fallando? Cuelgo el codigo a continuacion Muchas gracias #include <stdio.h> #include <stdlib.h> int main() { char d; bool termino = false; int n=0,i=0,j=0,dim1=0,dim2=0,resto=1,contador=1; printf("\n\n\n JUEGO CUATRO EN LINEA\n\n\n\n\n\n\n"); printf(" Nueva partida (S/N) "); switch (d) { case 'N':case 'n': termino = true; break; break; case 'S': case's': printf("\n\n\n\nIngresa la dimension del tablero de juego:\n\n"); dim1 = dim2; char matriz[dim1][dim2]; do { for (i=1;i<=dim1;i++) { for (j=1;j<=dim2;j++) { if ((matriz[i][j]!='X') && (matriz[i][j]!='O')) { } else { } } } while (resto<=(dim2*dim2)) { if ((resto%2)==0) { printf("\nJuega JUGADOR 1: "); matriz[dim1][n]='O'; printf ("%c\n",matriz [dim1 ][n ]); for (i=1;i<=dim1;i++) { for (j=1;j<=dim2;j++) { if ((matriz[i][j]=='X') || (matriz[i][j]=='O')) { matriz[dim1-1][n]='O'; /* corregir */ } if ((matriz[i][j]!='X') && (matriz[i][j]!='O')) { } else { if ((matriz[i][j]!='X') && (matriz[i][j]!='.')) { } else { } } } } } else { printf("\nJuega JUGADOR 2: "); matriz[dim1][n]='X'; printf ("%c\n",matriz [dim1 ][n ]); for (i=1;i<=dim1;i++) { for (j=1;j<=dim2;j++) { if ((matriz[i][j]=='X') || (matriz[i][j]=='O')) { matriz[dim1-1][n]='X'; /* corregir */ } if ((matriz[i][j]!='X') && (matriz[i][j]!='O')) { } else { if ((matriz[i][j]!='X') && (matriz[i][j]!='.')) { } else { } } } } } resto++; } }while (1); return 0; break; } while (!termino); }
|
|
|
32
|
Programación / Programación C/C++ / Re: Juego 4 en linea. Ayuda!!!
|
en: 5 Junio 2013, 21:18 pm
|
leosansan, eh estado tratando de seguir con el juego y hasta ahora he avanzado un poco aca abajo te cuelgo lo que puede hacer, a ver que tan bien esta o que me podes sugerir. Nota en el juego fije la coordenada Y (dim) porque tengo que colocar la ficha en el lugar mas bajo posible. Aguardo tus comentarios, saludos!!! #include <stdio.h> #include <iostream.h> int main() { char d; printf("\n\n\n JUEGO CUATRO EN LINEA\n\n\n\n\n\n\n"); printf(" Nueva partida (S/N)"); int n=0,i=0,j=0,dim=0,resto=0; printf("\n\n\n\nIngresa la dimension del tablero de juego:\n\n"); char matriz[dim][dim]; do { for (i=1;i<=dim;i++) { for (j=1;j<=dim;j++) { if ((matriz[i][j]!='X') && (matriz[i][j]!='O')) else } } while (resto<=(dim*dim)) { if ((resto%2)==0) { printf("\nJuega JUGADOR 1: "); matriz[dim][n]='O'; printf ("%c\n",matriz [dim ][n ]); for (i=1;i<=dim;i++) { for (j=1;j<=dim;j++) { if ((matriz[i][j]!='X') && (matriz[i][j]!='O')) else if ((matriz[i][j]!='X') && (matriz[i][j]!='.')) else } } } else { printf("\nJuega JUGADOR 2: "); matriz[dim][n]='X'; printf ("%c\n",matriz [dim ][n ]); for (i=1;i<=dim;i++) { for (j=1;j<=dim;j++) { if ((matriz[i][j]!='X') && (matriz[i][j]!='O')) else if ((matriz[i][j]!='X') && (matriz[i][j]!='.')) else } } } resto++; } }while (1); return 0; }
|
|
|
33
|
Programación / Programación C/C++ / Re: Juego 4 en linea. Ayuda!!!
|
en: 5 Junio 2013, 16:48 pm
|
Ok voy a tratar de verlo con algun compañero de clase que han tenido el mismo problema pero creo que lograron solucionarlo, cualquier cosa te comento luego para ver bien en que quedo esto jeje.
Saludos!!! y una vez mas gracias jeej
|
|
|
36
|
Programación / Programación C/C++ / Re: Juego 4 en linea. Ayuda!!!
|
en: 5 Junio 2013, 14:27 pm
|
\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 7 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 7 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 8 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 8 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function In function `int main()': \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 46 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] `dibujar_tablero' undeclared (first use this function) 46 [Error] (Each undeclared identifier is reported only once for each function it appears in.) \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 47 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] cannot convert `int (*)[((unsigned int)((int)dim_plus))]' to `int (*)[2]' for argument `1' to `void jugadores(int (*)[2], int, int)' \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 51 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] cannot convert `int (*)[((unsigned int)((int)dim_plus))]' to `int (*)[2]' for argument `1' to `void jugadores(int (*)[2], int, int)' C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp: At global scope: \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 61 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 61 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function In function `void dibujar_tablero(int (*)[2], int)': \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 61 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] `void dibujar_tablero(int (*)[2], int)' used prior to declaration C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp: At global scope: \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 83 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function \Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\Sin Nombre1.cpp 83 C:\Documents and Settings\MatiasC\Escritorio\Practico 1 Soluciones\C [Error] variable-size type declared outside of any function unrecognized option `-static-libstdc++'
Ese error me sale cuando intento compilar el codigo que me colgaste abajo.
|
|
|
37
|
Programación / Programación C/C++ / Re: Juego 4 en linea. Ayuda!!!
|
en: 5 Junio 2013, 13:54 pm
|
Muchas gracias leosansan, me ha sido de gran ayuda, pero cuando intento complilar el ultimo codigo me sale error cuando llamo al procedimiento imprimir_matriz; tampoco me dejan utilizar la el comando getchar
|
|
|
38
|
Programación / Programación C/C++ / Re: Juego 4 en linea. Ayuda!!!
|
en: 4 Junio 2013, 22:25 pm
|
Hola gracias por las prontas respuestas,
si pongo tan solo printf("%c",matriz[k][n]); me deja toda la matriz en X.
Logro hacer la matriz inicial pero cuando quiero colocar un valor no me da, se me modifican varios.
Les agradezco sus respuestas!
|
|
|
39
|
Programación / Programación C/C++ / Juego 4 en linea. Ayuda!!!
|
en: 3 Junio 2013, 16:47 pm
|
Buenas tardes soy nuevo en el foro y recien me estoy iniciando en el tema de la programacion, estoy intentando hacer el juego 4 en linea pero ando bastante trancado, elijo la dimension de mi tablero y muestro el mismo sin problemas pero cuando hago la primer jugada ya me muestra cualquier cosa. Les dejo el codigo abajo para ver si me pueden ayudar.
Desde ya, muchas gracias.
Estoy compilando con DevC++
Codigo:
#include <stdio.h> main() { // Elejimos la dimension del tablero int n,k; printf("Ingrese la dimension del tablero de juego: "); scanf("%d",&n); char matriz[n][n]; int i,j;
// Mostramos el tablero inicial for (i=0;i<n;i++) { for (j=0;j<n;j++) { printf("%c ",matriz[j]='-'); } printf("\n"); } printf("Haga su jugada: "); scanf("%d",&k); matriz[k][n]='X'; printf("%c",matriz[k][n]+matriz[j]); }
|
|
|
|
|
|
|