Need help to edit this code to allow user to find words in the grid that are touching horizontally, vertically, and diagonally adjacent.
For example, the board:
Q W E R T
A S D F G
Z X C V B
Y U A O P
G H J K L
contains the magic words WAS, WAXY, JOB.
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
int lx;
int ly;
char grid [10] [10];
int z;
int j;
int main()
{
// declare array with alphabet
char alphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z' };
printf ("Insert the width (Lx) and height (Ly) of the grid \n");
scanf ("%d %d", &lx, &ly);
for (z = 0; z < lx; z++)
{
for (j=0; j < ly; j++)
{
// print letters instead of dots
grid [z] [j] = alphabet[rand() % 26];
}
}
for (z = 0; z < lx; z++)
{
for (j=0; j < ly; j++)
{
printf ("%c", grid [z] [j]);
}
printf ("\n");
}
}