Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int board[8][8];
- int mode[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,-1},{-1,1},{1,-1}};
- int m,posx,posy;
- bool checknot(int x,int y,int place){
- if(x<0&&x==8&&y<0&&y==8) return false;
- if(board[x][y]==0) return false;
- if(board[x][y]==place){
- posx=x;
- posy=y;
- return true;
- }
- else return checknot(x+mode[m][0],y+mode[m][1],place);
- }
- void replace(int place){
- posx-=mode[m][0];
- posy-=mode[m][1];
- if(board[posx][posy]!=place){
- board[posx][posy]=place;
- }else return;
- replace(place);
- }
- int main(){
- int n;
- char c;
- int x,y;
- //White = 2 Black =1;
- board[3][3]=2;
- board[4][4]=2;
- board[3][4]=1;
- board[4][3]=1;
- scanf("%d",&n);
- for(int i=1;i<=n;i++){
- cin >> c >> x;
- x--;
- y=c-'a';
- int u=i%2;
- if(u==0) u=2;
- board[x][y]=u;
- for(int j=0;j<8;j++){
- m=j;
- if(checknot(x+mode[j][0],y+mode[j][1],u)){
- replace(u);
- }
- }
- }
- for(int i=0;i<8;i++){
- for(int j=0;j<8;j++){
- if(board[i][j]==0){
- printf(".");
- }else if(board[i][j]==1){
- printf("X");
- }else{
- printf("O");
- }
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement