Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int compare(int b, int w)
- {
- if(b==w)
- return 0;
- else if(b>w)
- return 1;
- else return -1;
- }
- void print_result(int b,int w)
- {
- switch (compare(b, w))
- {
- case 1:
- printf("Black\n");
- break;
- case 0:
- printf("Deuce\n");
- break;
- case -1:
- printf("White\n");
- default:
- break;
- }
- }
- int main(int argc, const char * argv[])
- {
- int n,cnt=0,i,j,white_judge = 0, black_judge = 0;
- scanf("%d",&n); // A n*n matrix
- char ChessBoard[100][100];
- while(cnt <n)
- scanf("%s",ChessBoard[cnt++]);
- for(i=0; i<n; i++)
- {
- for(j=0; j<n-4; j++)
- {
- if( ChessBoard[i][j] == ChessBoard[i][j+1] &&
- ChessBoard[i][j] == ChessBoard[i][j+2] &&
- ChessBoard[i][j] == ChessBoard[i][j+3] &&
- ChessBoard[i][j] == ChessBoard[i][j+4] &&
- ChessBoard[i][j] == 'x' ) black_judge = 1;
- else if( ChessBoard[i][j] == ChessBoard[i][j+1] &&
- ChessBoard[i][j] == ChessBoard[i][j+2] &&
- ChessBoard[i][j] == ChessBoard[i][j+3] &&
- ChessBoard[i][j] == ChessBoard[i][j+4] &&
- ChessBoard[i][j] == 'o' ) white_judge = 1;
- else
- {
- black_judge = black_judge;
- white_judge = white_judge;
- }
- }
- }
- for(i=0; i<n-4; i++)
- {
- for(j=0; j<n; j++)
- {
- if( ChessBoard[i][j] == ChessBoard[i+1][j] &&
- ChessBoard[i][j] == ChessBoard[i+2][j] &&
- ChessBoard[i][j] == ChessBoard[i+3][j] &&
- ChessBoard[i][j] == ChessBoard[i+4][j] &&
- ChessBoard[i][j] == 'x' ) black_judge = 1;
- else if( ChessBoard[i][j] == ChessBoard[i+1][j] &&
- ChessBoard[i][j] == ChessBoard[i+2][j] &&
- ChessBoard[i][j] == ChessBoard[i+3][j] &&
- ChessBoard[i][j] == ChessBoard[i+4][j] &&
- ChessBoard[i][j] == 'o' ) white_judge = 1;
- else
- {
- black_judge = black_judge;
- white_judge = white_judge;
- }
- }
- }
- for(i=0; i<n-4; i++)
- {
- for(j=0; j<n-4; j++)
- {
- if( ChessBoard[i][j] == ChessBoard[i+1][j+1] &&
- ChessBoard[i][j] == ChessBoard[i+2][j+2] &&
- ChessBoard[i][j] == ChessBoard[i+3][j+3] &&
- ChessBoard[i][j] == ChessBoard[i+4][j+4] &&
- ChessBoard[i][j] == 'x' ) black_judge = 1;
- else if( ChessBoard[i][j] == ChessBoard[i+1][j+1] &&
- ChessBoard[i][j] == ChessBoard[i+2][j+2] &&
- ChessBoard[i][j] == ChessBoard[i+3][j+3] &&
- ChessBoard[i][j] == ChessBoard[i+4][j+4] &&
- ChessBoard[i][j] == 'o' ) white_judge = 1;
- else
- {
- black_judge = black_judge;
- white_judge = white_judge;
- }
- }
- }
- for(i=n-1; i>3; i--)
- {
- for(j=0; j<n-4; j++)
- {
- if ( ChessBoard[i][j] == ChessBoard[i-1][j+1] &&
- ChessBoard[i][j] == ChessBoard[i-2][j+2] &&
- ChessBoard[i][j] == ChessBoard[i-3][j+3] &&
- ChessBoard[i][j] == ChessBoard[i-4][j+4] &&
- ChessBoard[i][j] == 'x' ) black_judge = 1;
- else if( ChessBoard[i][j] == ChessBoard[i-1][j+1] &&
- ChessBoard[i][j] == ChessBoard[i-2][j+2] &&
- ChessBoard[i][j] == ChessBoard[i-3][j+3] &&
- ChessBoard[i][j] == ChessBoard[i-4][j+4] &&
- ChessBoard[i][j] == 'o' ) white_judge = 1;
- else
- {
- black_judge = black_judge;
- white_judge = white_judge;
- }
- }
- }
- print_result(black_judge, white_judge);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment