Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #define dimentionEchequier 8
- int main()
- {
- char descriptionEchequier[dimentionEchequier][dimentionEchequier];
- int ligne, colonne;
- char contenuCase = ' ';
- int cavalierPrendPiece = 0;
- /*================================== Remplir le plateau ==========================================*/
- for (ligne = 0; ligne < dimentionEchequier; ligne++)
- {
- for (colonne = 0; colonne < dimentionEchequier; colonne++)
- {
- scanf("%c", &contenuCase);
- descriptionEchequier[ligne][colonne] = contenuCase;
- }
- }
- /*=================================================================================================*/
- /*=================== Determiner si un cavalier capture une piece ennemie =========================*/
- int i, j;
- for (i = 0; i < dimentionEchequier; i++)
- {
- for (j = 0; j < dimentionEchequier; j++)
- {
- if (descriptionEchequier[i][j] == 'C')
- {
- if (
- (isalpha(descriptionEchequier[i-2][j+1]) && islower(descriptionEchequier[i-2][j+1])
- && ((i-2) >= 0) && ((j+1) < 8)
- )
- ||(isalpha(descriptionEchequier[i-2][j-1]) && islower(descriptionEchequier[i-2][j-1])
- && ((i-2) >= 0) && ((j-1) >= 0)
- )
- ||(isalpha(descriptionEchequier[i-1][j+2]) && islower(descriptionEchequier[i-1][j+2])
- && ((i-1) >= 0) && ((j+2) < 8)
- )
- ||(isalpha(descriptionEchequier[i-1][j-2]) && islower(descriptionEchequier[i-1][j-2])
- && ((i-1) >= 0) && ((j-2) >= 0)
- )
- ||(isalpha(descriptionEchequier[i+2][j+1]) && islower(descriptionEchequier[i+2][j+1])
- && ((i+2) < 8) && ((j+1) < 8)
- )
- ||(isalpha(descriptionEchequier[i+2][j-1]) && islower(descriptionEchequier[i+2][j-1])
- && ((j-1) >= 0) && ((i+2) < 8)
- )
- ||(isalpha(descriptionEchequier[i+1][j-2]) && islower(descriptionEchequier[i+1][j-2])
- && ((j-2) >= 0) && ((i+1) < 8)
- )
- ||(isalpha(descriptionEchequier[i+1][j+2]) && islower(descriptionEchequier[i+1][j+2])
- && ((i+1) < 8) && ((j+2) < 8)
- )
- )
- cavalierPrendPiece = 1;
- }
- }
- }
- /*=================================================================================================*/
- /*================ Si un cavalier capture une piece ennemie, écrire "yes" sinon "no" =============*/
- if (cavalierPrendPiece)
- printf("yes");
- else
- printf("no");
- /*=================================================================================================*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement