Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Advanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dimentions = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int rows = dimentions[0];
- int cols = dimentions[1];
- var matrix = new char[rows][];
- var snake = Console.ReadLine().ToCharArray();
- var snakeQueue = new Queue<char>(snake);
- for (int row = 0; row < rows; row++)
- {
- matrix[row] = new char[cols];
- for (int col = 0; col < cols; col++)
- {
- char charToAdd = snakeQueue.Dequeue();
- matrix[row][col] = charToAdd;
- snakeQueue.Enqueue(charToAdd);
- }
- }
- Console.WriteLine(string.Join(Environment.NewLine, matrix.Select(r => string.Join("", r))));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement