当前位置:首页 » 操作系统 » android五子棋源码

android五子棋源码

发布时间: 2022-07-14 21:09:26

A. 五子棋人机简单算法,根据下面算法描述写代码,代码附解释(android)

这是问题?还是论文?
是否考虑一下棋谱匹配算法?

B. 请问怎么用Android studio做一个五子棋小游戏,学艺不精环境配置也不太弄

作为一个初学者,想用Android Studio做一个简易的五子棋,希望路过的大...
答:需要的话可以传你份源码

C. 求一个android五子棋的代码,要求:能在两台机器上联网对战,不需要机器人

同求,可以rmb收个

D. 请问我要用Android studio做一个五子棋的小游戏怎么配置开发环境

第一步,不考虑AI的情况下,先简单实现单人点击落子,点一次换一次黑白,落一次子判断一次输赢。第二步,加入socket通信两个人互落子。实现开局,落子,判断输赢,悔棋,认输,重新开局基本操作。第三步,加入AI,人机对战。

E. 找五子棋源代码c++

devc++运行通过,含注释

#include<bits/stdc++.h>

#include<windows.h>

#include<conio.h>

#include<ctime>

using namespace std;

void gotoxy(int x,int y) {

COORD pos = {x,y};

HANDLE hOut =GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(hOut,pos);

}//将光标移动到x,y点上

int mp[16][16]= {0},x1=0,x2=0;//地图,用来搜索五子连成的

void print(int x) {

gotoxy(x,1);

cout<<"┬";

for(int i=2; i<=14; i++) {

gotoxy(x,i);

cout<<"┼";

}

gotoxy(x,15);

cout<<"┴";

}//输出棋盘的中间部分

void gotoc() {

system("cls");

gotoxy(55,10);

cout<<"五 子 棋";

gotoxy(56,20);

cout<<"加载中...";

gotoxy(55,21);

cout<<"作者:北辰";

for(int j=0; j<100; j++) {

Sleep(17);

gotoxy(j+3,15);

cout<<" "<<j<<"%";

gotoxy(j,15);

cout<<"■";

}

system("cls");

for(int i=0; i<100; i++) {

for(int j=0; j<40; j++) {

gotoxy(i,j);

cout<<"■";

//SetColor(rand()%10);

}

}

system("cls");

}//加载界面函数

int main() {

gotoc();//加载

for(int i=2; i<=30; i+=2) {

gotoxy(i,0);

cout<<i/2;

}//横坐标

for(int i=1; i<=15; i++) {

gotoxy(0,i);

cout<<i;

}//纵坐标

gotoxy(2,1);

cout<<"┌";

for(int i=2; i<=14; i++) {

gotoxy(2,i);

cout<<"├";

}

gotoxy(2,15);

cout<<"└";//输出棋盘左侧

for(int i=4; i<=28; i+=2) {

print(i);

}//用一个循环来输出棋盘中间部分

gotoxy(30,1);

cout<<"┐";

for(int i=2; i<=14; i++) {

gotoxy(30,i);

cout<<"┤";

}

gotoxy(30,15);

cout<<"┘";//输出棋盘右侧

bool l=0;//没什么用的flag

long long m=2;//这个很重要,用来判断是该白棋走还是黑棋走,每次走完++,每次判断是偶数,该白棋,是奇数,该黑棋(一般用flag判断,这是我个人喜好)

gotoxy(0,17);

cout<<"游戏说明:白棋先走,落子请输入坐标,其他的不用我说了吧";//说明,一定要看

while(l=1) {

gotoxy(32,16);

int x,y;

cin>>x>>y;//读入xy坐标

gotoxy(32,16);

cout<<" ";

if(mp[x][y]!=0) {

gotoxy(32,16);

cout<<"此位置已有落子!";

Sleep(1000);

gotoxy(32,16);

cout<<" ";

continue;

}//很重要,用来判断此位置有没有落子

if(x>15&&y<=15) {

gotoxy(32,16);

cout<<"x坐标超出棋盘范围!";

Sleep(1000);

gotoxy(32,16);

cout<<" ";

continue;

}

if(y>15&&x<=15) {

gotoxy(32,16);

cout<<"y坐标超出棋盘范围!";

Sleep(1000);

gotoxy(32,16);

cout<<" ";

continue;

}

if(y>15&&x>15) {

gotoxy(32,16);

cout<<"x和y坐标均超出棋盘范围!";

Sleep(1000);

gotoxy(32,16);

cout<<" ";

continue;

}//以上三个if用来判断有没有超出棋盘大小

gotoxy(x*2,y);

if(m%2==0) {//是偶数,该白棋

cout<<"●";//输出棋子

mp[x][y]=1;

//横坐标搜索有没有连成五个

if(mp[x+1][y]==1&&mp[x+2][y]==1&&mp[x+3][y]==1&&mp[x+4][y]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-1][y]==1&&mp[x+1][y]==1&&mp[x+2][y]==1&&mp[x+3][y]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-2][y]==1&&mp[x-1][y]==1&&mp[x+1][y]==1&&mp[x+2][y]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-3][y]==1&&mp[x-2][y]==1&&mp[x-1][y]==1&&mp[x+1][y]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-4][y]==1&&mp[x-3][y]==1&&mp[x-2][y]==1&&mp[x-1][y]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

//竖

if(mp[x][y+1]==1&&mp[x][y+2]==1&&mp[x][y+3]==1&&mp[x][y+4]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x][y-1]==1&&mp[x][y+1]==1&&mp[x][y+2]==1&&mp[x][y+3]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x][y-2]==1&&mp[x][y-1]==1&&mp[x][y+1]==1&&mp[x][y+2]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x][y-3]==1&&mp[x][y-2]==1&&mp[x][y-1]==1&&mp[x][y+1]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x][y-4]==1&&mp[x][y-3]==1&&mp[x][y-2]==1&&mp[x][y-1]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

//斜''

if(mp[x+1][y+1]==1&&mp[x+2][y+2]==1&&mp[x+3][y+3]==1&&mp[x+4][y+4]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-1][y-1]==1&&mp[x+1][y+1]==1&&mp[x+2][y+2]==1&&mp[x+3][y+3]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-2][y-2]==1&&mp[x-1][y-1]==1&&mp[x+1][y+1]==1&&mp[x+2][y+2]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-3][y-3]==1&&mp[x-2][y-2]==1&&mp[x-1][y-1]==1&&mp[x+1][y+1]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x-4][y-4]==1&&mp[x-3][y-3]==1&&mp[x-2][y-2]==1&&mp[x-1][y-1]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

//斜'/'

if(mp[x-1][y+1]==1&&mp[x-2][y+2]==1&&mp[x-3][y+3]==1&&mp[x-4][y+4]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x+1][y-1]==1&&mp[x-1][y+1]==1&&mp[x-2][y+2]==1&&mp[x-3][y+3]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x+2][y-2]==1&&mp[x+1][y-1]==1&&mp[x-1][y+1]==1&&mp[x-2][y+2]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x+3][y-3]==1&&mp[x+2][y-2]==1&&mp[x+1][y-1]==1&&mp[x-1][y+1]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

if(mp[x+4][y-4]==1&&mp[x+3][y-3]==1&&mp[x+2][y-2]==1&&mp[x+1][y-1]==1) {

gotoxy(32,16);

cout<<"白棋获胜!";

return 0;

}

} else if(m%2==1) {//为奇数,该黑棋

cout<<"○";

mp[x][y]=2;

//横

if(mp[x+1][y]==2&&mp[x+2][y]==2&&mp[x+3][y]==2&&mp[x+4][y]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-1][y]==2&&mp[x+1][y]==2&&mp[x+2][y]==2&&mp[x+3][y]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-2][y]==2&&mp[x-1][y]==2&&mp[x+1][y]==2&&mp[x+2][y]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-3][y]==2&&mp[x-2][y]==2&&mp[x-1][y]==2&&mp[x+1][y]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-4][y]==2&&mp[x-3][y]==2&&mp[x-2][y]==2&&mp[x-1][y]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

//竖

if(mp[x][y+1]==2&&mp[x][y+2]==2&&mp[x][y+3]==2&&mp[x][y+4]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x][y-1]==2&&mp[x][y+1]==2&&mp[x][y+2]==2&&mp[x][y+3]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x][y-2]==2&&mp[x][y-1]==2&&mp[x][y+1]==2&&mp[x][y+2]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x][y-3]==2&&mp[x][y-2]==2&&mp[x][y-1]==2&&mp[x][y+1]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x][y-4]==2&&mp[x][y-3]==2&&mp[x][y-2]==2&&mp[x][y-1]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

//斜''

if(mp[x+1][y+1]==2&&mp[x+2][y+2]==2&&mp[x+3][y+3]==2&&mp[x+4][y+4]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-1][y-1]==2&&mp[x+1][y+1]==2&&mp[x+2][y+2]==2&&mp[x+3][y+3]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-2][y-2]==2&&mp[x-1][y-1]==2&&mp[x+1][y+1]==2&&mp[x+2][y+2]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-3][y-3]==2&&mp[x-2][y-2]==2&&mp[x-1][y-1]==2&&mp[x+1][y+1]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x-4][y-4]==2&&mp[x-3][y-3]==2&&mp[x-2][y-2]==2&&mp[x-1][y-1]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

//斜'/'

if(mp[x-1][y+1]==2&&mp[x-2][y+2]==2&&mp[x-3][y+3]==2&&mp[x-4][y+4]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x+1][y-1]==2&&mp[x-1][y+1]==2&&mp[x-2][y+2]==2&&mp[x-3][y+3]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x+2][y-2]==2&&mp[x+1][y-1]==2&&mp[x-1][y+1]==2&&mp[x-2][y+2]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x+3][y-3]==2&&mp[x+2][y-2]==2&&mp[x+1][y-1]==2&&mp[x-1][y+1]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

if(mp[x+4][y-4]==2&&mp[x+3][y-3]==2&&mp[x+2][y-2]==2&&mp[x+1][y-1]==2) {

gotoxy(32,16);

cout<<"黑棋获胜!";

return 0;

}

}

m++;//不要忘记++m

}

return 0;//这个没什么用了,不过比赛时不要忘记加哦,否则判0分

}

F. c语言五子棋代码,

package day17.gobang;

import java.util.Arrays;

public class GoBangGame {
public static final char BLANK='*';
public static final char BLACK='@';
public static final char WHITE='O';

public static final int MAX = 16;
private static final int COUNT = 5;
//棋盘
private char[][] board;

public GoBangGame() {

}
//开始游戏
public void start() {
board = new char[MAX][MAX];
//把二维数组都填充‘*’
for(char[] ary: board){
Arrays.fill(ary, BLANK);
}
}
public char[][] getChessBoard(){
return board;
}
public void addBlack(int x, int y) throws ChessExistException{
//@
//char blank = '*';
//System.out.println( x +"," + y + ":" + board[y][x] + "," + BLANK);
if(board[y][x] == BLANK){// x, y 位置上必须是空的才可以添棋子
board[y][x] = BLACK;
return;
}
throw new ChessExistException("已经有棋子了!");
}
public void addWhite(int x, int y)
throws ChessExistException{
if(board[y][x] == BLANK){// x, y 位置上必须是空的才可以添棋子
board[y][x] = WHITE;
return;
}
throw new ChessExistException("已经有棋子了!");
}
//chess 棋子:'@'/'O'
public boolean winOnY(char chess, int x, int y){
//先找到y方向第一个不是 blank的棋子
int top = y;
while(true){
if(y==0 || board[y-1][x]!=chess){
//如果y已经是棋盘的边缘, 或者的前一个不是chess
//就不再继续查找了
break;
}
y--;
top = y;
}
//向回统计所有chess的个数,如果是COUNT个就赢了
int count = 0;
y = top;
while(true){
if(y==MAX || board[y][x]!=chess){
//如果找到头 或者 下一个子不是chess 就不再继续统计了
break;
}
count++;
y++;
}
return count==COUNT;
}
//chess 棋子:'@'/'O'
public boolean winOnX(char chess, int x, int y){
//先找到x方向第一个不是 blank的棋子
int top = x;
while(true){
if(x==0 || board[y][x-1]!=chess){
//如果x已经是棋盘的边缘, 或者的前一个不是chess
//就不再继续查找了
break;
}
x--;
top = x;
}
//向回统计所有chess的个数,如果是COUNT个就赢了
int count = 0;
x = top;
while(true){
if(x==MAX || board[y][x]!=chess){
//如果找到头 或者 下一个子不是chess 就不再继续统计了
break;
}
count++;
x++;
}
return count==COUNT;
}

//chess 棋子:'@'/'O'
public boolean winOnXY(char chess, int x, int y){
//先找MAX向第一个不是 blank的棋子
int top = y;
int left = x;
while(true){
if(x==0 || y==0 || board[y-1][x-1]!=chess){
//如果x已经是棋盘的边缘, 或者的前一个不是chess
//就不再继续查找了
break;
}
x--;
y--;
top = y;
left=x;
}
//向回统计所有chess的个数,如果是COUNT个就赢了
int count = 0;
x = left;
y = top;
while(true){
if(x==MAX || y==MAX || board[y][x]!=chess){
//如果找到头 或者 下一个子不是chess 就不再继续统计了
break;
}
count++;
x++;
y++;
}
return count==COUNT;
}
//chess 棋子:'@'/'O'
public boolean winOnYX(char chess, int x, int y){
//先找到x方向第一个不是 blank的棋子
int top = y;
int left = x;
while(true){
if(x==MAX-1 || y==0 || board[y-1][x+1]!=chess){
//如果x已经是棋盘的边缘, 或者的前一个不是chess
//就不再继续查找了
break;
}
x++;
y--;
top = y;
left=x;
}
//向回统计所有chess的个数,如果是COUNT个就赢了
int count = 0;
x = left;
y = top;
while(true){
if(x==0 || y==MAX || board[y][x]!=chess){
//如果找到头 或者 下一个子不是chess 就不再继续统计了
break;
}
count++;
x--;
y++;
}
return count==COUNT;
}

public boolean whiteIsWin(int x, int y) {
//在任何一个方向上赢了,都算赢
return winOnY(WHITE, x, y) ||
winOnX(WHITE, x, y) ||
winOnXY(WHITE, x, y) ||
winOnYX(WHITE, x, y);
}
public boolean blackIsWin(int x, int y) {
return winOnY(BLACK, x, y) ||
winOnX(BLACK, x, y) ||
winOnXY(BLACK, x, y) ||
winOnYX(BLACK, x, y);
}

}

G. c语言编的五子棋源代码

//自定义控件,然后在工具箱拖过来用再把BackColor设置为Transparent
:ListBox
{
publicTransparentListBox()
{
this.SetStyle(ControlStyles.UserPaint,true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);
}
(EventArgse)
{
this.Invalidate();
base.OnSelectedIndexChanged(e);
}
protectedoverridevoidOnPaint(PaintEventArgse)
{
if(this.Focused&&this.SelectedItem!=null)
{
RectangleitemRect=this.GetItemRectangle(this.SelectedIndex);
e.Graphics.FillRectangle(Brushes.Green,itemRect);
}
for(inti=0;i<Items.Count;i++)
{
e.Graphics.DrawString(this.GetItemText(Items[i]),this.Font,newSolidBrush(this.ForeColor),this.GetItemRectangle(i));
}
base.OnPaint(e);
}
}

H. C#网络对战五子棋(c/s框架)

  • 一、源码描述
    这是一款比较好玩的五子棋游戏源码,支持网络对战,该源码比较适合大家学习
    交流使用,感兴趣朋友们的不要错过啊。
    二、功能介绍
    该源码主要实现了五子棋的基本功能,并且包含了网络对战的功能。
    三、注意事项
    1、开发环境为Visual Studio 2010,无数据库,使用.net 2.0开发。

I. 五子棋源码

/*
五子棋
*/

#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
#define ESC 0x011b
#define SPACE 0x3920

#define BILI 20
#define JZ 4
#define JS 3
#define N 19

int box[N][N];
int step_x,step_y ;
int key ;
int flag=1 ;

void draw_box();
void draw_cicle(int x,int y,int color);
void change();
void judgewho(int x,int y);
void judgekey();
int judgeresult(int x,int y);
void attentoin();

void attention()
{
char ch ;
window(1,1,80,25);
textbackground(LIGHTBLUE);
textcolor(YELLOW);
clrscr();
gotoxy(15,2);
printf("游戏操作规则:");
gotoxy(15,4);
printf("Play Rules:");
gotoxy(15,6);
printf("1、按左右上下方向键移动棋子");
gotoxy(15,8);
printf("1. Press Left,Right,Up,Down Key to move Piece");
gotoxy(15,10);
printf("2、按空格确定落棋子");
gotoxy(15,12);
printf("2. Press Space to place the Piece");
gotoxy(15,14);
printf("3、禁止在棋盘外按空格");
gotoxy(15,16);
printf("3. DO NOT press Space outside of the chessboard");
gotoxy(15,18);
printf("你是否接受上述的游戏规则(Y/N)");
gotoxy(15,20);
printf("Do you accept the above Playing Rules? [Y/N]:");
while(1)
{
gotoxy(60,20);
ch=getche();
if(ch=='Y'||ch=='y')
break ;
else if(ch=='N'||ch=='n')
{
window(1,1,80,25);
textbackground(BLACK);
textcolor(LIGHTGRAY);
clrscr();
exit(0);
}
gotoxy(51,12);
printf(" ");
}
}
void draw_box()
{
int x1,x2,y1,y2 ;
setbkcolor(LIGHTBLUE);
setcolor(YELLOW);
gotoxy(7,2);
printf("Left, Right, Up, Down KEY to move, Space to put, ESC-quit.");
for(x1=1,y1=1,y2=18;x1<=18;x1++)
line((x1+JZ)*BILI,(y1+JS)*BILI,(x1+JZ)*BILI,(y2+JS)*BILI);
for(x1=1,y1=1,x2=18;y1<=18;y1++)
line((x1+JZ)*BILI,(y1+JS)*BILI,(x2+JZ)*BILI,(y1+JS)*BILI);
for(x1=1;x1<=18;x1++)
for(y1=1;y1<=18;y1++)
box[x1][y1]=0 ;
}

void draw_circle(int x,int y,int color)
{
setcolor(color);
setlinestyle(SOLID_LINE,0,1);
x=(x+JZ)*BILI ;
y=(y+JS)*BILI ;
circle(x,y,8);
}

void judgekey()
{
int i ;
int j ;
switch(key)
{
case LEFT :

if(step_x-1<0)
break ;
else
{
for(i=step_x-1,j=step_y;i>=1;i--)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(i<1)break ;
step_x=i ;
judgewho(step_x,step_y);
break ;
}
case RIGHT :

if(step_x+1>18)
break ;
else
{
for(i=step_x+1,j=step_y;i<=18;i++)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(i>18)break ;
step_x=i ;
judgewho(step_x,step_y);
break ;
}
case DOWN :

if((step_y+1)>18)
break ;
else
{
for(i=step_x,j=step_y+1;j<=18;j++)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(j>18)break ;
step_y=j ;
judgewho(step_x,step_y);
break ;
}
case UP :

if((step_y-1)<0)
break ;
else
{
for(i=step_x,j=step_y-1;j>=1;j--)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(j<1)break ;
step_y=j ;
judgewho(step_x,step_y);
break ;
}
case ESC :
break ;

case SPACE :
if(step_x>=1&&step_x<=18&&step_y>=1&&step_y<=18)
{
if(box[step_x][step_y]==0)
{
box[step_x][step_y]=flag ;
if(judgeresult(step_x,step_y)==1)
{
sound(1000);
delay(1000);
nosound();
gotoxy(30,4);
if(flag==1)
{
setbkcolor(BLUE);
cleardevice();
setviewport(100,100,540,380,1);
/*定义一个图形窗口*/
setfillstyle(1,2);
/*绿色以实填充*/
setcolor(YELLOW);
rectangle(0,0,439,279);
floodfill(50,50,14);
setcolor(12);
settextstyle(1,0,5);
/*三重笔划字体, 水平放?5倍*/
outtextxy(20,20,"The White Win !");
setcolor(15);
settextstyle(3,0,5);
/*无衬笔划字体, 水平放大5倍*/
outtextxy(120,120,"The White Win !");
setcolor(14);
settextstyle(2,0,8);
getch();
closegraph();
exit(0);
}
if(flag==2)
{
setbkcolor(BLUE);
cleardevice();
setviewport(100,100,540,380,1);
/*定义一个图形窗口*/
setfillstyle(1,2);
/*绿色以实填充*/
setcolor(YELLOW);
rectangle(0,0,439,279);
floodfill(50,50,14);
setcolor(12);
settextstyle(1,0,8);
/*三重笔划字体, 水平放大8倍*/
outtextxy(20,20,"The Red Win !");
setcolor(15);
settextstyle(3,0,5);
/*无衬笔划字体, 水平放大5倍*/
outtextxy(120,120,"The Red Win !");
setcolor(14);
settextstyle(2,0,8);
getch();
closegraph();
exit(0);
}
}
change();
break ;
}
}
else
break ;
}
}

void change()
{
if(flag==1)
flag=2 ;
else
flag=1 ;
}

void judgewho(int x,int y)
{
if(flag==1)
draw_circle(x,y,15);
if(flag==2)
draw_circle(x,y,4);
}

int judgeresult(int x,int y)
{
int j,k,n1,n2 ;
while(1)
{
n1=0 ;
n2=0 ;
/*水平向左数*/
for(j=x,k=y;j>=1;j--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*水平向右数*/
for(j=x,k=y;j<=18;j++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}

/*垂直向上数*/
n1=0 ;
n2=0 ;
for(j=x,k=y;k>=1;k--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*垂直向下数*/
for(j=x,k=y;k<=18;k++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}

/*向左上方数*/
n1=0 ;
n2=0 ;
for(j=x,k=y;j>=1,k>=1;j--,k--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*向右下方数*/
for(j=x,k=y;j<=18,k<=18;j++,k++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}

/*向右上方数*/
n1=0 ;
n2=0 ;
for(j=x,k=y;j<=18,k>=1;j++,k--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*向左下方数*/
for(j=x,k=y;j>=1,k<=18;j--,k++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}
return(0);
break ;
}
}

void main()
{
int gdriver=VGA,gmode=VGAHI;
clrscr();
attention();
initgraph(&gdriver,&gmode,"c:\\tc");
/* setwritemode(XOR_PUT);*/
flag=1 ;
draw_box();
do
{
step_x=0 ;
step_y=0 ;
/*draw_circle(step_x,step_y,8); */
judgewho(step_x-1,step_y-1);
do
{
while(bioskey(1)==0);
key=bioskey(0);
judgekey();
}
while(key!=SPACE&&key!=ESC);
}
while(key!=ESC);
closegraph();
}



J. 用android studio怎么做一个简单的五子棋

http://tieba..com/p/1568464014 参考C的写法 安卓语法改一下就行

热点内容
密码子的原料是什么 发布:2024-09-19 09:11:42 浏览:347
半夜编程 发布:2024-09-19 09:11:36 浏览:104
海康威视存储卡质量如何 发布:2024-09-19 08:55:35 浏览:940
python3默认安装路径 发布:2024-09-19 08:50:22 浏览:517
环卫视频拍摄脚本 发布:2024-09-19 08:35:44 浏览:418
sqlserveronlinux 发布:2024-09-19 08:16:54 浏览:256
编程常数 发布:2024-09-19 08:06:36 浏览:952
甘肃高性能边缘计算服务器云空间 发布:2024-09-19 08:06:26 浏览:162
win7家庭版ftp 发布:2024-09-19 07:59:06 浏览:717
数据库的优化都有哪些方法 发布:2024-09-19 07:44:43 浏览:269