Input: grid[][] = {"axmy",
"bgdf",
"xeet",
"raks"};
Output: Yes
a x m y
b g d f
x e e t
r a k s
Input: grid[][] = {"axmy",
"brdf",
"xeet",
"rass"};
Output : No
The general idea of what output should be. I have already coded the grid:
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
int x;
int y;
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 (x) and height (y) of the grid \n");
scanf ("%d %d", &x, &y);
for (z = 0; z < x; z++)
{
for (j=0; j < y; j++)
{
// print letters instead of dots
grid [z] [j] = alphabet[rand() % 26];
}
}
for (z = 0; z < x; z++)
{
for (j=0; j < y; j++)
{
printf ("%c", grid [z] [j]);
}
printf ("\n");
}
}