❶ c語言編的五子棋源代碼
源程序前半部分
/*載入頭文件*/
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<bios.h>
#include<conio.h>
/*編譯預處理,定義按鍵碼*/
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
/*若想在游戲中途退出, 可按 Esc 鍵*/
#define ESC 0x011b
/*SPACE鍵表示落子*/
#define SPACE 0x3920
/*設置偏移量*/
#define OFFSET 20
#define OFFSET_x 4
#define OFFSET_y 3
/*定義數組大小*/
#define N 19
/*定義全局變數*/
int status[N][N]; /*定義的數組,保存狀態*/
int step_x,step_y;/*行走的坐標*/
int key ; /*獲取按下的鍵盤的鍵*/
int flag; /*玩家標志*/
/*自定義函數原型*/
void DrawBoard();
void DrawCircle(int x,int y,int color);
void Alternation();
void JudgePlayer(int x,int y);
void Done();
int ResultCheck(int x,int y);
void WelcomeInfo();
void ShowMessage();
/*定義函數*/
/*顯示歡迎信息函數*/
void WelcomeInfo()
{
char ch ;
/*移動游標到指定位置*/
gotoxy(12,4);
/*顯示歡迎信息*/
printf("Welcome you to gobang word!");
gotoxy(12,6);
printf("1.You can use the up,down,left and right key to move the chessman,");
gotoxy(12,8);
printf(" and you can press Space key to enter after you move it !");
gotoxy(12,10);
printf("2.You can use Esc key to exit the game too !");
gotoxy(12,12);