编写一个程序求解字谜游戏问题

问题描述:输入是由一些字母和单词构成的二维数组,目标是找出字谜中的单词,这些单词可以是水平、垂直或沿对角线以任何方向放置。
 编写一个程序求解字谜游戏问题
  t h i s     找出 this、two、fat、that
  w a t s
  o a h g
  f g d t
#include <stdio.h>
#include <string.h>
#define alphaTableMax (4)

typedef enum tableDir{LEFT = 0, RIGHT, UP, DOWN, LEFTUP, RIGHTUP, LEFTDOWN, RIGHTDOWN} tableDir;

typedef struct tableAddr
{
	int row;
	int colum;
}tableAddr;

static char alphaTable[alphaTableMax][alphaTableMax] = { {'t', 'h', 'i', 's'},
														 {'w', 'a', 't', 's'},
													     {'o', 'a', 'h', 'g'},
														 {'f', 'g', 'd', 't'}};

int findLeftLetter(const char* word, int row, int colum, int letterNum, tableAddr alphaAddr[])
{
	if (alphaTable[row][colum - letterNum] == word[letterNum])
	{
		alphaAddr[letterNum].row = row;
		alphaAddr[letterNum].colum = col
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值