黑白棋遊戲

2021-07-15 19:11:09 字數 1044 閱讀 9796

用c++封裝了一下,只完成了乙個雛形, 有很多功能沒有新增上, 但**的行數已經縮短了很多了。

#include#include#include#includeusing namespace std;

class chess

int counter();///計數器,計算棋子個數;

const friend void draw(chess &, chess &);///畫出棋盤,每落一子更新一次;

friend int win(chess &, chess &);///通過棋子個數判斷輸贏

void change(int, int, chess &);///進行落子,並將與之相符規則的棋子轉化為自己顏色

static bool judge(int x, int y)///小判斷,若x,y處有棋子,則不允許落子}}

if(chessmen[x-1][y]==s1.color)}}

if(chessmen[x+1][y]==s1.color)}}

if(chessmen[x+1][y+1]==s1.color)

break;}}

}if(chessmen[x-1][y-1]==s1.color)

break;}}

}if(chessmen[x-1][y+1]==s1.color)

break;}}

}if(chessmen[x+1][y-1]==s1.color)

break;}}

}if(flag)

chessmen[x][y]=color;

else

}int main()

s1.change(x, y, s2);

system("cls"); ///清屏

draw(s1, s2);

cout<<"請落白棋"<>x>>y;

while(chess::judge(x, y))

s2.change(x, y, s1);

system("cls"); ///清屏

draw(s1, s2);

}cout<<"遊戲結束!"<

黑白棋遊戲

黑白棋遊戲 time limit 10000ms memory limit 65536k total submit 9 accepted 5 case time limit 1000ms description 問題描述 黑白棋遊戲的棋盤由4 4方格陣列構成。棋盤的每一方格中放有1枚棋子,共有8枚白...

黑白棋遊戲

include include using namespace std char e 30 30 int a 30 30 int c 30 int x 30 int y 30 intf int n,int sum int pos sum 2 n int cnt 0 int flag 0 int w ...

黑白棋遊戲程式

include include include include include include using namespace std int qi 8 8 define size 8 void display char board size return no of moves void make...