资源简介
用c语言实现的连连看算法,对c语言基础,数据结构等能有较好了解
代码片段和文件信息
#include
#include
#include
#include
typedef struct{
int x;
int y;
}stPos;
typedef struct{
stPos position;
char type;
bool IsClear;
}stUnion;
//#define UNION_ARRAY_XLEN 16
//#define UNION_ARRAY_YLEN 16
#define UNION_ARRAY_XLEN 9
#define UNION_ARRAY_YLEN 9
#define GET_MIN(x y) (x <= y ? x : y)
#define GET_MAX(x y) (x >= y ? x : y)
extern void InitUnionArray(stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern void PrintfUnionArray(stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsUnionClear(stUnion * ucUnion);
extern void ClearUnion(stUnion * ucUnion);
extern bool IsSameTypeUnion(stUnion * ucFirUnion stUnion * ucSecUnion);
extern bool IsSameUnion(stUnion * ucFirUnion stUnion * ucSecUnion);
extern bool IsNextUnion(stUnion * ucFirUnion stUnion * ucSecUnion);
extern bool IsHoriLine(stUnion * ucFirUnion stUnion * ucSecUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsVerLine(stUnion * ucFirUnion stUnion * ucSecUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsLine(stUnion * ucFirUnion stUnion * ucSecUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsNearLeftBorder(stUnion * ucUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsNearRightBorder(stUnion * ucUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsNearUpBorder(stUnion * ucUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsNearDownBorder(stUnion * ucUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool GetHoriTwoUnion(stUnion * ucUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN] stUnion *FirUnion stUnion * SecUnion);
extern bool GetVerTwoUnion(stUnion * ucUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN] stUnion *FirUnion stUnion * SecUnion);
extern bool IsLineUnderTwoTurn(stUnion * ucFirUnion stUnion * ucSecUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
extern bool IsTwoUnionClear(stUnion * ucFirUnion stUnion * ucSecUnion stUnion ucUnionArray[][UNION_ARRAY_YLEN]);
void InitUnionArray(stUnion ucUnionArray[][UNION_ARRAY_YLEN])
{
int i = 0;
int j = 0;
srand((int)time(0));
for(j = 0; j < UNION_ARRAY_YLEN; j++)
{
for(i = 0; i < UNION_ARRAY_XLEN; i++)
{
ucUnionArray[i][j].position.x = i;
ucUnionArray[i][j].position.y = j;
ucUnionArray[i][j].type = (char)(65 + (int)(10.0*rand()/(RAND_MAX+1.0)));
ucUnionArray[i][j].IsClear = false;
//if(!UnionArray[i][j].IsClear)
//printf(“ %c “ UnionArray[i][j].type);
//else
//printf(“ “);
}
//printf(“\n“);
}
}
void PrintfUnionArray(stUnion ucUnionArray[][UNION_ARRAY_YLEN])
{
int i = 0;
int j = 0;
for(i = 0; i < UNION_ARRAY_XLEN; i++)
printf(“ %d “ i);
printf(“\n\n“);
for(j = 0; j < UNION_ARRAY_YLEN; j++)
{
for(i = 0; i < UNION_ARRAY_XLEN; i++)
{
if(!IsUnionClear(&ucUnionArray[i][j]))
printf(“ %c “ ucUnionArray[i][j].type);
else
pr
相关资源
- C++中头文件与源文件的作用详解
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 利用C++哈希表的方法实现电话号码查
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- 个人日常财务管理系统(C语言)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- C语言实现的一个内存泄漏检测程序
- DES加密算法C语言实现
- LINUX下命令行界面的C语言细胞游戏
- 用单片机控制蜂鸣器播放旋律程序(
- 学校超市选址问题(数据结构C语言版
- 电子时钟 有C语言程序,PROTEUS仿真图
- 尚观培训linux许巍老师关于c语言的课
- 算符优先语法分析器(C语言编写)
评论
共有 条评论