< pcur.y ? ppre.y : pcur.y;if(t + 1 == k)goto FIND;for(int i = t + 1;i < k ;i++)if(GridID[i][ppre.x] != 0)return false;if(i == k)goto FIND;}else if(ppre.y == pcur.y){ k = ppre.x > pcur.x ? ppre.x : pcur.x;t = ppre.x < pcur.x ? ppre.x : pcur.x;if(t + 1 == k)goto FIND;for(int i = t + 1;i < k ;i++)if(GridID[ppre.y][i] != 0) return false;if(i == k)goto FIND;}return false;FIND: point[pn].x = pcur.x,point[pn].y = pcur.y;pn++;point[pn].x = ppre.x,point[pn].y = ppre.y; pn++; return true;}bool Match_one_corner(POINT ppre,POINT pcur)//判断两者是否能一折相消{int left,right,top,bottel,x = ppre.x,y = ppre.y;Explot(ppre,&left,&right,&top,&bottel);ppre.y = top - 1;RESEARCHX: if(ppre.y < bottel)ppre.y++;else goto BACK;if(Match_direct(ppre,pcur)) goto FIND;else goto RESEARCHX;BACK:ppre.y = y; ppre.x = left - 1;RESEARCHY:if(ppre.x < right)ppre.x++;else goto REBACK;if(Match_direct(ppre,pcur)) goto FIND;else goto RESEARCHY;REBACK:pn = 0; return false;FIND:point[pn].x = x,point[pn].y = y,pn++;return true;}bool Match_two_corner(POINT ppre,POINT pcur)//判断两者是否能两折相消{int left,right,top,bottel,x = ppre.x,y = ppre.y;Explot(ppre,&left,&right,&top,&bottel);ppre.y = top - 1;RESEARCHX: if(ppre.y < bottel)ppre.y++;else goto BACK;if(Match_one_corner(ppre,pcur)) goto FIND;else goto RESEARCHX;BACK:ppre.y = y; ppre.x = left - 1;RESEARCHY:if(ppre.x < right)ppre.x++;else goto REBACK;if(Match_one_corner(ppre,pcur)) goto FIND;else goto RESEARCHY;REBACK:pn = 0;return false;FIND:point[pn].x = x,point[pn].y = y,pn++;return true;}void Explot(POINT point,int *left,int *right,int *top,int *bottel){int x = point.x,y = point.y; x++;while(x <= COL + 1 &&GridID[y][x] == 0)x++;*right = x - 1;x = point.x; x--;while(x >= 0&&GridID[y][x] == 0)x--;*left= x + 1;x = point.x; y++;while(y <= ROW + 1 &&GridID[y][x] == 0)y++;*bottel= y - 1;y = point.y; y--;while(y >= 0&&GridID[y][x] == 0)y--;*top= y + 1;}/消除操作void Link (){switch(pn){case 2:Des_direct();break;case 3:Des_one_corner(); break;case 4:Des_two_corner();break;default : break;} }void Des_direct (){TranstoPhycoor(&point[0].x,&point[0].y);TranstoPhycoor(&point[1].x,&point[1].y);DrawLine(point[0].x,point[0].y,point[1].x,point[1].y);Sleep(250);iPaint(point[0].x,point[0].y,point[1].x,point[1].y);}void Des_one_corner(){TranstoPhycoor(&point[0].x,&point[0].y);TranstoPhycoor(&point[1].x,&point[1].y);TranstoPhycoor(&point[2].x,&point[2].y);DrawLine(point[0].x,point[0].y,point[1].x,point[1].y);DrawLine(point[1].x,point[1].y,point[2].x,point[2].y);Sleep(250);iPaint(point[0].x,point[0].y,point[1].x,point[1].y);iPaint(point[1].x,point[1].y,point[2].x,point[2].y);}void Des_two_corner(){TranstoPhycoor(&point[0].x,&point[0].y);TranstoPhycoor(&point[1].x,&point[1].y);TranstoPhycoor(&point[2].x,&point[2].y);TranstoPhycoor(&point[3].x,&point[3].y);DrawLine(point[0].x,point[0].y,point[1].x,point[1].y);DrawLine(point[1].x,point[1].y,point[2].x,point[2].y);DrawLine(point[2].x,point[2].y,point[3].x,point[3].y);Sleep(250);iPaint(point[0].x,point[0].y,point[1].x,point[1].y);iPaint(point[1].x,point[1].y,point[2].x,point[2].y);iPaint(point[2].x,point[2].y,point[3].x,point[3].y);}void DrawLine (int x1,int y1,int x2,int y2){setlinestyle(PS_SOLID,NULL,3);setcolor(RGB(90,43,9));line(x1 + 21,y1 + 24,x2 + 21,y2 + 24);}void iPaint (long x1,long y1,long x2,long y2){int minx,miny,maxx,maxy;if(x1 == x2){maxy = y1 > y2? y1:y2;miny = y1 < y2? y1:y2;for(int i = miny; i <= maxy;i += 48)putimage(x1,i,&image2);}else if(y1 == y2){maxx = x1 > x2? x1:x2;minx = x1 < x2? x1:x2;for(int j = minx; j <= maxx;j += 42 )putimage(j,y1,&image2);} }/void GridPhy_coor(int& leftx,int& lefty)//转化为标准物理坐标{leftx = ((leftx - leftedge) / 42) * 42 + leftedge;lefty = ((lefty - topedge) / 48) * 48 + topedge;}void ExchaVal(GridInfor& pre,GridInfor& cur)//交换格子信息{pre.GridID = cur.GridID;pre.idx = cur.idx;pre.idy = cur.idy;pre.leftx = cur.leftx;pre.lefty = cur.lefty;}void Init_Grid(GridInfor& grid)//初始化格子{grid.GridID = 0;grid.idx = 0;grid.idy= 0;grid.leftx= 0;grid.lefty = 0;}void TranstoPhycoor (int* idx,int* idy)//图纸坐标转变为屏幕坐标{int x ,y;x =*idx,y = *idy;*idy = (y - 1) * 48 + leftedge;*idx = (x - 1) * 42 + topedge;}
- 使用 Visual Studio 2019 【在更】基础 | C 语言笔记
- C语言实现检测Linux设备网络状态
- Excel用函数求C语言的最高分,excel怎样用函数求最高分
- 《草根自媒体达人运营实战》一一1.4 自媒体的形式
- c语言任意长度小数加减法,[c++]大数运算
- 18 如何安装SCO Unix《精通Unix下C语言编程与项目实践》读书笔记
- 电脑c语言保存键是哪个好,9个值得保存的计算机技巧!
- 使用gosec工具对golang项目进行安全检查
- 雷达编程实战之Firmware内存优化
- ECC OpenCV 项目开发实战--对图像进行对齐