Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void FillMatrix(string[,] matrix, string snakeInput, int rowCount, int colCount)
- {
- Queue<string> snake = new Queue<string>();
- for (int i = 0; i < snakeInput.Length; i++)
- {
- snake.Enqueue(snakeInput[i].ToString());
- }
- int rowCounter = 1;
- for (int rows = rowCount - 1; rows >= 0; rows--)
- {
- int currCols = 0;
- if (rowCounter % 2 != 0)
- {
- currCols = colCount - 1;
- }
- else
- {
- currCols = 0;
- }
- while (currCols >= 0 && currCols < colCount)
- {
- string currLetter = snake.Dequeue();
- matrix[rows, currCols] = currLetter;
- snake.Enqueue(currLetter);
- if (rowCounter % 2 != 0)
- {
- currCols--;
- }
- else
- {
- currCols++;
- }
- }
- rowCounter++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment