Advertisement
Montoya-Romina-Anahi

Struct

Oct 28th, 2021
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <windows.h>//gotoxy
  4.  
  5. #define dim 7
  6. #define NULA 0
  7. #define VACIA 2
  8. #define FICHA 10
  9.  
  10. using namespace std;
  11. ///////////////////////////////////////////////////////////
  12.     COORD coordenadas={0,0};
  13.     int tablero[dim][dim];
  14.     /////////////////////////////////////////////////////////
  15.  
  16. typedef struct{
  17.     int tablero[dim][dim];
  18.     int nFichas;//NUMERO DE FICHAS
  19.     int nMovimientos;//NUMERO DE MOVMIENTOS REALIZADOS EN EL JUEGO
  20.     string tipoEstado;//ESTADO QUE SE ENCUENTA EN EL JUEGO
  21.     int tcelda[dim][dim];//ESTADO DE CADA CELDA
  22. }tJUEGO;
  23.  
  24. ////////////////// DECLARACION DE FUNCIONES ////////////////////////
  25. void mostrar(int x, int y){
  26.     coordenadas.X = x;
  27.     coordenadas.Y = y;
  28.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coordenadas);
  29. }
  30. void tableroInicial(int [dim][dim]);
  31. void mFOR(int,int);
  32. //////////////////////////////////////////
  33. int main(){
  34.     tableroInicial(tablero);   
  35.     mostrar(dim,dim);
  36.     return 0;
  37. }
  38. //////////////////////////////////////////
  39. void tableroInicial(int tablero[dim][dim]){
  40.     for (int fila = 0; fila < 7; fila++)    {
  41.         for (int columna = 0;columna < 7; columna++){
  42.             if (fila == 3 && columna == 3){
  43.                 tablero[fila][columna] = VACIA;
  44.             }else{
  45.                 if( (fila < 2 || fila > 4)&&(columna < 2 || columna > 4) ){
  46.                     tablero[fila][columna] = NULA;
  47.                 }else{
  48.                     tablero[fila][columna] = FICHA;
  49.                 }
  50.             }
  51.         }
  52.     }
  53. }
  54. /////////////////////////////////////////////////////////////////////7
  55. void mFOR(int dim, int dim){
  56.     for (int fila = 0; fila < dim; fila++)  {
  57.         for (int columna = 0; columna < dim; columna++){
  58.             mostrar(10+columna*5,5+fila);
  59.             cout<<tablero[fila][columna];
  60.         }
  61.         cout<<" "<<endl;
  62.     }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement