- 时间:2021-02-12 12:12 编辑:王金璐 来源:蚂蚁资源 阅读:238
- 扫一扫,手机访问
摘要:大家好,今天给大家介绍关于五八弟源码(第八区)的相关内容,详细讲解求一个C语言小程序(五子棋)源代码,求五子棋C源代码,五子棋源码等,希望可以帮助到您。
求一个C语言小程序(五子棋)源代码,原发行者:毛庆丰#包括#imenten10voidwelcome(); voidinitqipan(); voidshowqi(Inti); voidsave(int); voidpanduan(Intp); voidheqi(); Voidover(); Intzouqihang(); Intzouqilie(); / ** ***************结构************************** / structzupuobiao {intx [ n * n]; inty [n * n];} weizhi [n * n]; / ***************** PRIMER功能******************************* **********(){INTP = 0;欢迎 (); initqipan(); for(p = 1; p <= n * n; p ++){weiz [p] .x [p] = zouqihang();威智[p]。 y [p] = zouqilie();保存(P); showkqi(p); Panduan(p);}如果(p == n * n)heqi();超过();} / ***** ************创建一个棋盘************************ **** / voidinitqipan(){INTI,J; for(i = 0; i
求五子棋C源代码,这有点好了,我没有尝试过它/ *五五* / #include #include #include #include #included #define left 0x4b00 #define右0x4d00 #define下来0x5000 #define向上0x4800 #define esc 0x011b #define Esc 0x011b #define空间0x3920 #define bili 20 #define jz 4 #define js 3 #define n 19 int box [n] [n]; int调整_x,step_y;界面钥匙; int标志= 1; void draw_box(); void draw_clicle(int x,int y,int color); void变化();空白法官。 void法官(); int x,int y); void tententoin(); void注意(){char ch;窗口(1,1,80,25); TextBackground(LightBlue); TextColor(黄色); clrscr(); gotoxxy(15,2); Printf(“游戏操作规则:”); gotoxy(15,4); printf(“播放规则:”); gotoxy(15,6); Printf(“1,按左和右方向”); gotoxy(15,8); printf(“1.按左,右,向上,向下移动键“); Gotoxy(15,10); Printf(”2,按下空间来确定滴注器“); Gotoxy(15,12); Printf(”2.按空间要放置一块“); Gotoxy(15,14); printf”3,禁止按下董事会外的空间“); gotoxy(15,16); printf(”3.不要按Shssboard外的空间)) ; Gotoxy(15,18); Printf(“您接受上述游戏规则(Y / N)); Gotoxy(15,20); Printf(”您接受上述播放规则吗?[Y / N]: “);虽然(1){gotoxy(60,20); ch = get();如果(ch =='y'|| ch =='y')中断;否则if(ch =='n'| | Ch =='n'){窗口(1,1,80,25); TextBackground(黑色); TextColor(LightGray); CLRSCR();出口(0); Gotoxy(51,12); Printf(“ );}}}} void draw_box(){int x1,x2,y1,y2; setBkcolor(LightBlue);雕刻(黄色);gotoxy(7,2); printf(“左,右,向上,向下移动,空间放置,Esc-quit。”); for(x1 = 1,y1 = 1,y2 = 18; x1 = 1; i - )if(box [i] [j] == 0){draw_circle(step_cracle(step_x,step_y,lightblue; break;}如果(i18) break; else {for(i = step_x + 1,j = step_y; i18)中断; step_x = i; refalwho(step_x,step_y); break;} ucase down:如果((step_y + 1)> 18)中断;否则for(i = step_x,j = step_y + 1; j18)中断; step_y = j; refalwho(step_x,step_y); break;} case:if(step_y-1)= 1; j-if(box [i ] [j] == 0){draw_circle(step_x,step_y,lightblue);中断;}如果(j = 1 && step_x = 1 && step_y = 1; j- - ){if(box [j] ==标志) n1 ++; else break;} / *水平到右边* / for(j = x,k = y; j = 5){return(1); break;} / *垂直向上* / n1 = 0; n2 = 0;对于(j = x,k = y; k> = 1; k - ){if(b牛[j] [k] ==标志)n1 ++;否则打破;} / *垂直向下* / for(j = x,k = y; k = 5){return(1);打破;} / *到左上角* / n1 = 0; n2 = 0; for(j = x,k = y; j> = 1,k> = 1; j - ,k - ){if(box [j] [k] == flag)n1 ++; else break} / *到右侧(j = x,k = y; j = 5){return(1);打破;} / *到右上角* / n1 = 0; n2 = 0; for(j = x,k = y; j = 1; j ++,k - ){if(box [j] [k] == flag)n1 ++;否则打破;} / *左下数字* / for(j = x,k = y j> = 1,k = 5){return(1);休息;}返回(0); break; void main()}}} void main()}}} void main()}} vga,gmode = vgahi; clrscr();注意力 (); EnitGraph(&gdriver,和Gweode,C:\\ Tc“); / * setwritemode; * / flag = 1; draw_box(); do {step_x = 0; step_y = 0; / * draw_circle(step_x,step_y,8); * /法官(STEP_X-1,STEP_Y-1);做{while(bioskey(1)== 0); key = bioskey(0); QuiceKey();} while(key!= space && key!= esc);} while(key!= esc);特写镜头();
五子棋源码,/ *五子* /#包括 #include #include #include #dflude left 0x4b00 #define右0x4d00 #define down 0x5000 #define向上0x4800#define esc 0x011b #define space 0x3920 #define bili 20 #define jz 4 #define js 3 #define n 19 int box [n] [n]; int staw_x,step_y;界面钥匙; int标志= 1; void draw_box(); void draw_cicle int x,int y,int颜色; void变化(); void remywho(int x,int y); void法官(); int judgeresult(int x,int y); void tententoin(); void注意(){char ch;窗口(1,80,25); TextBackground(LightBlue); TextColor(黄色); clrscr(); gotoxy(15,2); Printf(“游戏操作规则:”); gotoxy(15,4打印机(“播放规则:”); gotoxy(15,6); printf(“1,按下左和下方方向移动棋子”); gotoxy(15,8); printf(“1.按左,向上,向上,向下键移动”); gotoxy(15,10); printf(“2,按空间来确定滴注器”); gotoxy(15,12); printf(“2.按空间放置碎片”); gotoxy(15,14); Printf(“3,禁止董事会禁止空间”); gotoxy(15,16); printf(“3.不要按SHSSBOARD之外的空间”); gotoxy(15,18); Printf(“你接受上述游戏规则(Y / N)); gotoxy(15,20); printf(“你接受上面的播放规则吗?[Y / N]:”);虽然(1){gotoxy(60,20); ch = getche(); if(ch =='y'|| ch =='y')中断;否则if(ch =='n'|| ch =='n'){窗口(1,1,80,25); Textbackground(黑色“); TextColor(LightGray); CLRSCR();退出(0);} Gotoxxy(51,12); printf(”“); void draw_box(){int x1,x2,y1,y2; setBkcolor(LightBlue);雕刻(黄色); gotoxy(7,2); printf(“左,右,向上,向下移动,空间放置,Esc-quit。”);对于(x1 = 1,y1 = 1,y2 = 18; x1 = 1; i - )if(框[i] [j] == 0){draw_circle;休息;如果(我<=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> 18)休息;否则{for(i = step_x + 1,j = step_y;我<1)break ; step_x=i ; judgewho(step_x,step_y); break ; } case RIGHT : if(step_x+1> 18)突破; step_x = i;法官踏步_ _,普及;突破;}}案例关闭:如果((step_y + 1)> 18)中断;否则{for(i = step_x,j = step_y + 1; j <=18;i++) if(box[i][j]==0) { draw_circle(step_x,step_y,LIGHTBLUE); break ; } if(i> 18)中断; step_y = j;法官(Step_x,Step_y);休息;}} uce:如果((step_y-1)<=18;j++) if(box[i][j]==0) { draw_circle(step_x,step_y,LIGHTBLUE); break ; } if(j> = 1; j - if(box [i] [j] == 0){draw_circle(step_crcle(step_x,step_y,lightblue break;}如果(j <0) break ; else { for(i=step_x,j=step_y-1;j> = 1 && step_x <1)break ; step_y=j ; judgewho(step_x,step_y); break ; } case ESC : break ; case SPACE : if(step_x> = 1 && step_y <=18&&step_y> = 1; j - {if(框[j] [k] ==标志)n1 ++; else break;} / *水平右* / for(j = x,k = y; j <=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> = 5){return(1);中断;} / *垂直向上* / n1 = 0;n2 = 0; for(j = x,k = y; k> = 1; k - ){if(box [j] ==标志)n1 ++;否则打破;} / *垂直下* / for(j = x,k = y; k <=18;j++) { if(box[j][k]==flag) n2++; else break ; } if(n1+n2-1> = 5){return(1);打破;} / *到左上角* / n1 = 0; n2 = 0; for(j = x,k = y; j> = 1,k> = 1; j - ,k - ){if(box [j] ==标志)n1 ++;否则打破;} / *到右下方* / for(j = x,k = y; j <=18;k++) { if(box[j][k]==flag) n2++; else break ; } if(n1+n2-1> = 5){return(1);打破; } / *到右上级* / n1 = 0; n2 = 0; for(j = x,k = y; j <=18,k<=18;j++,k++) { if(box[j][k]==flag) n2++; else break ; } if(n1+n2-1> = 1; j ++,k - ){if(box [j] [k] = = flag)n1 ++;否则打破;} / *到左下方* / for(j = x,k = y; j> = 1,k <=18,k> = 5){return(1);休息;}返回0); break;}} void main(){int gdriver = Vga,Gemode = Vgahi; clrscr();注意力 (); EnitGraph(&gdriver,和Gweode,C:\\ Tc“); / * setwritemode(XOR_PUT); * / flag = 1; draw_box();do {step_x = 0; step_y = 0; / * draw_circle(step_x,step_y,8); * /法官(STEP_X-1,STEP_Y-1);做{while(bioskey(1)== 0); key = bioskey(0); Quicekey();} while(key!= space && key!= esc);} while(key!= esc); corthcuge();
责任编辑(王金璐)
以上就是关于**五八弟源码,第八区**的全部内容,了解更多请关注蚂蚁资源网。
- 好牛通
- 急求:五子棋的源代码(数据结构),每一步都要有解释的!!!,#include<iostream.h>#include<stdlib.h>#define Num 15//********************************************************//类class T//定义类用来封装所有相关函数和变量{char board[Num][Num];//用数组board[Num][Num]来定义棋盘public:void PrintMenu(); //打印菜单 说明游戏规则和方法 void PrintBoard(); //打印棋盘void GameStart(char*,int &,int &,char); //下棋int whichwin(int,int,char); //判断那个选手赢void Choice(char &); //是否再玩void Setboard(); //重置棋盘};//****************************************************************//main主函数void main ()//主函数{T s;//说明类的一个对象s s.PrintMenu();//通过s调用PrintMenu函数提示如何游戏char player1[20],player2[20];//玩家姓名int FirstWin=0,SecondWin=0,Draws=0,x,y,N;//说明变量,赋初值为0以待计算输赢结果char choice='Y';cin.ignore(20,'\n');//输入输出流,前面如果有输入把输入行所有字符取空,以便后面的输入从新的一行开始cout<<"请输入第一个玩家姓名:";cin.getline(player1,20);//连续读取数据cout<<"请输入第二个玩家姓名:";cin.getline(player2,20);while(choice=='Y'||choice=='y')//条件成立,执行{ s.Setboard();//调用Setboard函数 N=0;while(N<=(Num*Num)){s.PrintBoard();//打印棋盘s.GameStart(player1,x,y,'O');N++;//记录已下棋子数if(s.whichwin(x-1,y-1,'O'))//返回值不为0则条件成立{s.PrintBoard();cout<<player1<<"赢了。"<<endl;FirstWin++;//记录赢局数break;//终止本次循环}s.PrintBoard();//同上s.GameStart(player2,x,y,'X');N++;if(s.whichwin(x-1,y-1,'X')){s.PrintBoard();cout<<player2<<"赢了。"<<endl;SecondWin++;break;}if(N==(Num*Num)){cout<<"和棋!";Draws++;//记录平局数break;}}s.Choice(choice);//给玩家提供一次选择是否再玩的机会}//输出游戏输赢次数cout<<player1<<"赢了"<<FirstWin<<"次"<<endl;cout<<player2<<"赢了"<<SecondWin<<"次"<<endl;cout<<"和"<<Draws<<"次"<<endl;cout<<"谢谢使用。"<<endl;cout<<"任意键继续。"<<endl;cin.get();//很必要的,目的是空度换行字符}//*******************************************************************//定义公有成员函数void T::PrintMenu(){cout<<"欢迎进入五子棋游戏!\n";cout<<"******************************************"<<endl;cout<<"\t游戏说明:"<<endl<<endl;cout<<"1.第一个玩家用O第二个玩家用X;"<<endl;cout<<"2.请根据提示输入所要走的行和列;"<<endl;cout<<"3.按<Enter>下棋。"<<endl;cout<<"
- 2021-02-12 12:12:59
- 飞创科技
- #include "iostream"#include <iomanip>using namespace std;const int M=20;const int N=20;int main(){char weizhi[M][N];int k,i,j,x,y,flag=0;cout<<"欢迎使用简易双人对战五子棋游戏"<<endl;cout<<"五子棋棋谱如下:"<<endl;for(k=0;k<=N;k++)cout<<setw(3)<<setfill(' ')<<k;cout<<endl;for(i=1;i<=M;i++){cout<<setw(3)<<setfill(' ')<<i;for(j=1;j<=N;j++){weizhi[i][j]='-';cout<<setw(3)<<setfill(' ')<<weizhi[i][j];}cout<<endl;}while(flag==0){//红方落子cout<<"请红方输入落子位置:"<<endl;loop1:cout<<"请输入落子的行数:";cin>>x;cout<<"请输入落子的列数:";cin>>y;if(weizhi[x][y]=='-'){weizhi[x][y]='*';for(k=0;k<=N;k++)cout<<setw(3)<<setfill(' ')<<k;cout<<endl;for(i=1;i<=M;i++){cout<<setw(3)<<setfill(' ')<<i;for(j=1;j<=N;j++)cout<<setw(3)<<setfill(' ')<<weizhi[i][j];cout<<endl;}}else{cout<<"你不能在这落子,请重新选择落子位置:"<<endl;goto loop1;}//判断胜利for(i=1;i<=M-4;i++){for(j=1;j<=N-4;j++){if(weizhi[i][j]=='*' && weizhi[i][j+1]=='*' && weizhi[i][j+2]=='*' && weizhi[i][j+3]=='*' && weizhi[i][j+4]=='*'){cout<<"恭喜红方获得简易双人对战五子棋的胜利!耶~~~"<<endl;flag=1;break;}if(weizhi[i][j]=='*' && weizhi[i+1][j]=='*' && weizhi[i+2][j]=='*' && weizhi[i+3][j]=='*' && weizhi[i+4][j]=='*'){cout<<"恭喜红方获得简易双人对战五子棋的胜利!耶~~~"<<endl;flag=1;break;}if(weizhi[i][j]=='*' && weizhi[i+1][j+1]=='*' && weizhi[i+2][j+2]=='*' && weizhi[i+3][j+3]=='*' && weizhi[i+4][j+4]=='*'){cout<<"恭喜红方获得简易双人对战五子棋的胜利!耶~~~"<<endl;flag=1;break;}if(flag==1)break;}}//蓝方落子cout<<"请蓝方输入落子位置:"<<endl;loop2:cout<<"请输入落子的行数:";cin>>x;cout<<"请输入落子的列数:";cin>>y;if(weizhi[x][y]=='-'){weizhi[x][y]='#';for(k=0;k<=N;k++)cout<<setw(3)<<setfill(' ')<<k;cout<<endl;for(i=1;i<=M;i++){cout<<setw(3)<<setfill(' ')<<i;for(j=1;j<=N;j++)cout<<setw(3)<<setfill(' ')<<weizhi[i][j];cout<<endl;}}else{cout<<"你不能在这落子,请重新选择落子位置:";goto loop2;}//判断胜利for(i=1;i<=M-4;i++){for(j=1;j<=N-4;j++){if(weizhi[i][j]=='#' && weizhi[i][j+1]=='#' && weizhi[i][j+2]=='#' && weizhi[i][j+3]=='#' && weizhi[i][j+4]=='#'){cout<<"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~"<<endl;flag=1;break;}if(weizhi[i][j]=='#' && weizhi[i+1][j]=='#' && weizhi[i+2][j]=='#' && weizhi[i+3][j]=='#' && weizhi[i+4][j]=='#'){cout<<"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~"<<endl;flag=1;break;}if(weizhi[i][j]=='#' && weizhi[i+1][j+1]=='#' && weizhi[i+2][j+2]=='#' && weizhi[i+3][j+3]=='#' && weizhi[i+4][j+4]=='#'){cout<<"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~"<<endl;flag=1;break;}if(flag==1)break;}}}return 0;}二人对弈五子棋游戏,棋子分为黑白两种;当同一种颜色的棋子实现五子连珠时即为获胜;通过按下棋盘上的状态键,用以标示该黑子落子还是白子落子;运行成功;你可以在这基础上修改一下
- 2021-02-12 12:12:59
- erpang666
- ....bmp ;wuzi.ini res .\qzb.bmp ..h StdAfx.H RoundButton1..\.cpp Dlgoption.h readme.txt Release .rc2.h ROUNDBUTTON.CPP ROUNDBUTTON;qzh.\7.exe ..bmp resource.dep 7.dsp 7.cpp StdAfx.h CDC2.......\mask..;7...h 7.rc 7Dlg.h dim.h Dlgoption.\7.ico ...\...cpp 7Dlg.cpp CDC2CWinApp CDialog CDataExchange CWnd CBitmap CSize LoadBitmap CreateCompatibleDC SelectObject DeleteObject LoadIcon GetSystemMenu CMenu CString LoadString AppendMenu GetModuleFileName GetDC EnableWindow IsIconic CPaintDC SendMessage GetSystemMetrics CRect GetClientRect DrawIcon CPoint MessageBox WritePrivateProfileString GetPrivateProfileString CDC CheckRadioButton CRgn SetPixelV CButton SetWindowRgn CreateEllipticRgnIndirect ClientToScreen GetParent ScreenToClient MoveWindow SaveDC GetSysColor GetWindowText CreateEllipticRgn SelectClipRgn SetBkMode DrawState TextOut RestoreDC BitBlt 7.cpp 7..\.cpp RoundButton1
- 2021-03-23 18:35:01