codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
// TRAZA TABLERO AJEDREZ - ESTRUCTURAS Y FUNCIONES #include <iostream> using namespace std; #define N 8 struct s_chess { char ch[N][N]; }; // El parámetro debe pasar por referencia void iniciaJuego(s_chess &); void verTablero(s_chess); // La matriz tiene un elemento más por fila, el final de cadena ('\0') char tablero[N][N+1] = {"tacrdcat", "pppppppp", "________", "________", "________", "________", "PPPPPPPP", "TACDRCAT"}; int main() { s_chess game; iniciaJuego(game); verTablero(game); } void iniciaJuego(s_chess &T) { for(int i=0; i<N; i++) for(int j=0; j<N; j++) T.ch[i][j] = tablero[i][j]; } void verTablero(s_chess T) { for(int i=0; i<N; i++) for(int j=0; j<N; j++) cout << T.ch[i][j] << (j==N-1 ? "\n\n":" "); }
Private
[
?
]
Run code
Submit