資源簡介
參考別人寫的一個,在win-tc上運行通過,完成跳馬的遍歷
代碼片段和文件信息
#include
#include
#define??Nx??8
#define??Ny??8
/*?棋盤行,列數?*/
#define??M??8
/*?馬下一步最多能夠跳的地方?*/
static?int?mark=0;
int?A[Nx][Ny];
int?Movex[M]?=?{-2?-1??1??2??2??1?-1?-2};
int?Movey[M]?=?{?1??2??2??1?-1?-2?-2?-1};
/*?馬可能跳的位置的相對橫縱坐標?*/
void?output()
{
????int?ij;
????for(i?=?0;i?????{
????????for(j?=?0;j?????????printf(“%4d“A[i][j]);
????????putchar(‘\n‘);
????????putchar(‘\n‘);
????}
????putchar(‘\n‘);
????getch();
}
/*?輸出棋盤矩陣每一個點的值?*/
int?jumpfun(int?x0int?y0int?step)
{
????int?ijxyx1y1x2y2counttempdk=0;
????int?weight[M]position[M];
????for(i?=?0;i?????{
????????count?=?0;
????????x1?=?x0?+?Movex[i];
????????y1?=?y0?+?Movey[i];
????????/*?下一個位置的坐標?*/
????????if(
- 上一篇:C語言通訊錄
- 下一篇:windows游戲開發黑白棋益智游戲
評論
共有 條評論