生活随笔
收集整理的這篇文章主要介紹了
串串字连环
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目大意:
串串字連環(huán)是利用一個(gè)5x5大小的英文字母格子進(jìn)行的游戲。游戲規(guī)則是,連接上下左右/對(duì)角線方向上相鄰的字母,組成一個(gè)單詞。
const int dx
[8] ={-1,-1,-1,1,1,1,0,0};
const int dy
[8] ={-1,0,1,-1,0,1,-1,1};bool hasword(int y
,int x
,condt string
&word
){if(!inRange(y
,x
))return false;if(board
[y
][x
] !=word
[0])return false;if(word
.size() == 1)return true;for(int direction
= 0,direction
<8;++direction
){int nextY
= y
+dy
[direction
] , nextX
= x
+dx
[direction
];if(hasword(nextY
,nextX
,word
.substr(1))return true;}return false;
}
總結(jié)
以上是生活随笔為你收集整理的串串字连环的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。