Advertisement
Guest User

szachy.cpp

a guest
Feb 17th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include "chessBoard.h"
  3.  
  4. #define WAR
  5.  
  6. int main( int argc, char* argv[] )
  7. {
  8.     if( argc != 3 )
  9.     {
  10.         printf( " Za malo argumentow \n\n" );
  11.         return -1;
  12.     }
  13.  
  14.     //szachownica (wsp)
  15.     //  y0
  16.     //  5
  17.     //  4
  18.     //  3
  19.     //  2
  20.     //  1
  21.     //    1 2 3 4 5  x0
  22.  
  23.     #ifndef WAR
  24.     int x0 = atoi( argv[ 1 ] );//1
  25.     int y0 = atoi( argv[ 2 ] );//5
  26.     #else
  27.     int x0 = 1;
  28.     int y0 = 8;
  29.     #endif
  30.     if( x0 > CHESSBOARD_SIZE || x0 < 1 || y0 > CHESSBOARD_SIZE || y0 < 1 )
  31.     {
  32.         printf( " Zle parametry \n\n" );
  33.         return 0;
  34.     }
  35.  
  36.     int** chess_board = createChessBoard( CHESSBOARD_SIZE );
  37.     point offset[ HORSE_MOVES ] = { {2,1}, {1,2}, {-1,2}, {-2,1}, {-2,-1}, {-1,-2}, {1,-2}, {2,-1} };
  38.                                         // 0      1       2       3       4        5       6       7
  39.  
  40.     if( root( chess_board, CHESSBOARD_SIZE, 1, x0-1, y0-1, offset ) )
  41.         printChessBoard( chess_board, CHESSBOARD_SIZE );
  42.     else
  43.         printf( " BLAD : nie udalo sie znalezc drogi skoczka z zadanej pozycji\n\n" );
  44.  
  45.     freeChessBoard( &chess_board );
  46.  
  47.     return 1;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement