c語言 三子棋

2021-09-05 13:09:12 字數 1389 閱讀 5553

華不多說 直接上**

#define  _crt_secure_no_warnings 1

#include #include #include //這是乙個三子棋的遊戲

//1.使用者選擇遊戲或者退出

//2.使用者選擇電腦先還是人先

//3.開始落子

//4.判斷輸贏

#define row 3

#define col 3

char arr[row][col];

void menu()

void choose()

void init(char arr[row][col])

}}void print(char arr[row][col])

printf("\n");

printf(" -- -- --\n"); }}

int isfull()

} }return 1;

}int win()

} //判斷列

for (int col = 0; col < col; col++) }

//判斷對角線

if (arr[0][0] == arr[1][1] && arr[0][0] == arr[2][2] && arr[2][2] != ' ')

if (arr[2][0] == arr[1][1] && arr[2][0] == arr[0][2] && arr[2][0] != ' ')

return ' ';

}int winner()

if (win() == 'o')

if (isfull() == 1)

return 0;

}void playermove()

if (arr[row][col] == ' ')

else

}}void computermove()

if (arr[row][col] == ' ')

else

}}void game()

winner();

computermove();

print(arr);

if (winner() == 1)

winner();}}

else if (ch == 0)

winner();

playermove();

print(arr);

if (winner() == 1)

winner();

} }}

int main()

game();

menu(); }

printf("結束遊戲\n");

system("pause");

return 0;

}

C語言 三子棋

使用工具 vs2017 分為三部分 game.h 函式宣告 game.c 實現函式功能 test.c main函式 棋盤為3 3的矩陣 規則 1.每回合玩家與電腦只能放置一枚棋子 2.已有棋子的位置不能再放置棋子 3.若有一方的三枚棋子可連城一條直線,則勝利 4.若棋盤棋子已經布滿,但是雙方沒有一方...

三子棋(c語言)

今天做了乙個三子棋小遊戲,寫了好久卻只完成了一部分,先把這部分分享給大家吧!望大家給點建議和指導,最後判斷輸贏部分到現在還沒構思出來,嘿嘿!game.h define crt secure no warnings 1 ifndef game h define game h include inclu...

c語言 三子棋

c語言三子棋 來完善一下三子棋 game.h define crt secure no warnings 1 ifndef game h define game h include include include include define row 3 define col 3 void menu...