Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P05SnakeMoves
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] dimensions = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int rows = dimensions[0];
- int cols = dimensions[1];
- string input = Console.ReadLine();
- int snakeLength = input.Length;
- var matrix = new string[rows, cols];
- var queue = new Queue<char>(input);
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- char currentSymbol = queue.Peek();
- matrix[i, j] = currentSymbol.ToString();
- queue.Enqueue(queue.Dequeue());
- }
- }
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- Console.Write(matrix[row,col]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement