Advertisement
Guest User

Untitled

a guest
May 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define dimentionEchequier 8
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9.     char descriptionEchequier[dimentionEchequier][dimentionEchequier];
  10.     int ligne, colonne;
  11.     char contenuCase = ' ';
  12.     int cavalierPrendPiece = 0;
  13.  
  14.  
  15.     /*================================== Remplir le plateau ==========================================*/
  16.  
  17.     for (ligne = 0; ligne < dimentionEchequier; ligne++)
  18.     {
  19.         for (colonne = 0; colonne < dimentionEchequier; colonne++)
  20.         {
  21.             scanf("%c", &contenuCase);
  22.             descriptionEchequier[ligne][colonne] = contenuCase;
  23.         }
  24.     }
  25.  
  26.     /*=================================================================================================*/
  27.  
  28.     /*=================== Determiner si un cavalier capture une piece ennemie =========================*/
  29.  
  30.     int i, j;
  31.     for (i = 0; i < dimentionEchequier; i++)
  32.     {
  33.         for (j = 0; j < dimentionEchequier; j++)
  34.         {
  35.             if (descriptionEchequier[i][j] == 'C')
  36.             {
  37.                     if (
  38.                         (isalpha(descriptionEchequier[i-2][j+1]) && islower(descriptionEchequier[i-2][j+1])
  39.                         && ((i-2) >= 0) && ((j+1) < 8)
  40.                         )
  41.                         ||(isalpha(descriptionEchequier[i-2][j-1]) && islower(descriptionEchequier[i-2][j-1])
  42.                         && ((i-2) >= 0) && ((j-1) >= 0)
  43.                         )
  44.                         ||(isalpha(descriptionEchequier[i-1][j+2]) && islower(descriptionEchequier[i-1][j+2])
  45.                         && ((i-1) >= 0) && ((j+2) < 8)
  46.                         )
  47.                         ||(isalpha(descriptionEchequier[i-1][j-2]) && islower(descriptionEchequier[i-1][j-2])
  48.                         && ((i-1) >= 0) && ((j-2) >= 0)
  49.                         )
  50.                         ||(isalpha(descriptionEchequier[i+2][j+1]) && islower(descriptionEchequier[i+2][j+1])
  51.                         && ((i+2) < 8) && ((j+1) < 8)
  52.                         )
  53.                         ||(isalpha(descriptionEchequier[i+2][j-1]) && islower(descriptionEchequier[i+2][j-1])
  54.                         && ((j-1) >= 0) && ((i+2) < 8)
  55.                         )
  56.                         ||(isalpha(descriptionEchequier[i+1][j-2]) && islower(descriptionEchequier[i+1][j-2])
  57.                         && ((j-2) >= 0) && ((i+1) < 8)
  58.                         )
  59.                         ||(isalpha(descriptionEchequier[i+1][j+2]) && islower(descriptionEchequier[i+1][j+2])
  60.                         && ((i+1) < 8) && ((j+2) < 8)
  61.                         )
  62.                        )
  63.                         cavalierPrendPiece = 1;
  64.  
  65.             }
  66.         }
  67.     }
  68.  
  69.     /*=================================================================================================*/
  70.  
  71.     /*================ Si un cavalier capture une piece ennemie, écrire "yes" sinon  "no" =============*/
  72.  
  73.     if (cavalierPrendPiece)
  74.         printf("yes");
  75.     else
  76.         printf("no");
  77.  
  78.     /*=================================================================================================*/
  79.  
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement