源代码打印(共11页).doc
《源代码打印(共11页).doc》由会员分享,可在线阅读,更多相关《源代码打印(共11页).doc(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上 井字棋C语言源代码#include#include#include#include#include#include#define ENTER 0x1c0d#define esc 0x11b#define up 0x4800#define down 0x5000#define left 0x4b00#define right 0x4d00int i,j,x1,y1,v,n,m,key,d,e,p,q,h,o,x,y,k;int a33=0,0,0,0,0,0,0,0,0;int score33=0,0,0,0,0,0,0,0,0;char s 30;int main(
2、)void drawone();void drawtwo();void drawthree();void drawfour();void drawfive();void drawsix();void xianka();int renzouqi();int xuanze();int py( int a3);int jisuanji();int xuanzeyouxi();int bioskey(int cmd);xianka();drawone(); if(key=bioskey(0)=ENTER) drawtwo(); key=bioskey(0); if(key=ENTER) drawfou
3、r(); v=1; while(v=1) drawthree(); n=xuanze(); x1=220; y1=230; circle(220,230,20); o=pan_y(a);while(o=2) if(n=1)n=renzouqi();if(n=-1)n=jisuanji(); o=pan_y(a); drawsix(); getch(); drawfive(); v=xuanzeyouxi(); closegraph();/*显卡驱动*/void xianka()int graphdriver,graphmode; int driver=DETECT,mode; initgrap
4、h(&driver,&mode,); graphdriver=DETECT; initgraph(&graphdriver,&graphmode,);/*定义判赢函数*/int pan_y(int a3)int n,b,c,i,j,k=2;for(i=0;i3;i+)n=ai0; b=ai1; c=ai2; if(n+b+c=3) k=1; if(n+b+c=-3) k=-1;for(j=0;j3;j+)n=a0j;b=a1j;c=a2j;if(n+b+c=3) k=1;if(n+b+c=-3) k=-1;n=a00; b=a11; c=a22; if(n+b+c=3) k=1;if(n+b+
5、c=-3) k=-1; n=a02; b=a11; c=a20; if(n+b+c=3) k=1;if(n+b+c=-3) k=-1;if(a00!=0&a01!=0&a02!=0&a10!=0&a11!=0&a12!=0&a20!=0&a21!=0&a22!=0)k=0;return k;/*选择哪一方先下*/int xuanze() key=bioskey(0); n=-1; while(key!=ENTER) if(key=up) setfillstyle(1,3); floodfill(471,150,4); setfillstyle(1,14); floodfill(471,200,
6、4); n=-1; if(key=down) setfillstyle(1,14); floodfill(471,150,4); setfillstyle(1,3); floodfill(550,200,4); n=1; key=bioskey(0);return n;/*界面1*/void drawone() for(i=1;i6;i+)setcolor(i);settextstyle(0,HORIZ_DIR,i);outtextxy(250-43*i,80*i,Welcome To You);setcolor(10);settextstyle(0,VERT_DIR,2);outtextxy
7、(20,80,* How Do You Do *);settextstyle(0,VERT_DIR,2);outtextxy(620,80,* How Do You Do *);setcolor(13);line(20,0,20,479);line(22,0,22,479);line(600,0,600,479);line(602,0,602,479);/*界面2*/void drawtwo() cleardevice();setbkcolor(2);setviewport(0,0,639,479,0);settextstyle(1,0,6);setfillstyle(1,12);rectan
8、gle(230,10,370,280);floodfill(150,350,13);settextstyle(1,0,5);setbkcolor(0);outtextxy(250,100,Jing);outtextxy(280,100,Zi);outtextxy(280,200,Qi);settextstyle(1,0,3);setcolor(0);outtextxy(250,300,Designed by: wang xian zhen);outtextxy(402,350,sun jian );outtextxy(402,400, xu ke );/*界面3*/void drawthree
9、() cleardevice();setbkcolor(14);setviewport(0,0,639,479,1);setfillstyle(1,2);setcolor(4);line(70,180,370,180);line(70,280,370,280);line(170,80,170,380);line(270,80,270,380);line(470,180,570,180);rectangle(470,130,570,230);setfillstyle(1,3);floodfill(500,150,4);settextstyle(1,0,2);outtextxy(475,190,p
10、erson);outtextxy(475,140,computer);settextstyle(3,0,1);outtextxy(468,260,person);circle(557,274,10);setfillstyle(1,13);floodfill(555,274,4);outtextxy(468,300,computer);circle(557,308,10);setfillstyle(1,3);floodfill(555,300,4);/*界面4*/void drawfour() int i,x5=300,y5=200,r=100,x6=350,y6=200;cleardevice
11、();setbkcolor(8);setcolor(14);settextstyle(1,0,5);setviewport(0,0,639,479,0);for(i=0;i80) setcolor(14); circle(x1,y1,20); setcolor(4); circle(x,y,20); x1=x; y1=y; if(key=down) x=x1; y=y1+100; if(y70) setcolor(14); circle(x1,y1,20); setcolor(4); circle(x,y,20); x1=x; y1=y; if(key=right) x=x1+100; y=y
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 源代码 打印 11
限制150内