Home c# How to make a word generator with auto-filling

How to make a word generator with auto-filling

Author

Date

Category

Guys tell me how to write the code or please please offer your code option.

In general, I need to do. My idea is that I need to implement the action code so that the array of code can be fill in (an array with the String type) and this array with the words to scatter on random fields, that is, vertically, horizontally, up, down, Left, right, etc. An example as shown in the picture. I will be very grateful if you help me!


Answer 1

Suppose you have a two-dimensional array of the type char in the size of Columns * Rows, and an array of Wordsar lines with the words that will be recorded. The code will look something like this: here is the code I can write:

int [,] dir = int [,] {{0,1} {0, -1} {1 0} { - 1.0} {1,1} {1, -1} { - 1,1} { - 1, -1}}; // Row directions
for (int i = 0; i & lt; wordsar.length; i ++) {// Rewor
  // Coordinates of the cell in which the word will begin
  int cellx = random.range (0, rows), celly = random.range (0, columns);
  do {
    // Choose the direction
    int tmpdir = dir [random.range (0, dir.length)];
  while (isscellacceptale (TMPDIR) == FALSE);
  // write a word
  For (int j = 0; j & lt; Wordsar [i] .length; j ++) {
    Array [Cellx] [Celly] = Wordsar [i] .charat (j);
    CellX + = TMPDIR [0];
    Celly + = TMPDIR [1];
  }
}
BOOL ISCELLACCEPTABLE (INT CELLX, INT CELLY, STRING WORD, INT [] DIRECTION) {
  INT WORDLENGTH = Word.Length;
  if (direction [0] == 1 & amp; & amp; columns - cellx & gt; WordLengTh-1 ||
    Direction [0] == -1 & amp; & amp; Cellx & GT; WordLength ||
    Direction [1] == 1 & amp; & amp; Celly & gt; WordLength ||
    Direction [1] == -1 & amp; & amp; Rows - Celly & GT; WordLengTh-1)
      RETURN FALSE;
  ELSE RETURN TRUE;

Code wrote without compilation, so that there may be errors and sieves. The only possible error – if the word is long and it will not allow it to write from the initial line in any direction

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions