Advertisement
GabrielDas

Untitled

May 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace P05SnakeMoves
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. int[] dimensions = Console.ReadLine()
  13. .Split(" ", StringSplitOptions.RemoveEmptyEntries)
  14. .Select(int.Parse)
  15. .ToArray();
  16.  
  17. int rows = dimensions[0];
  18. int cols = dimensions[1];
  19.  
  20. string input = Console.ReadLine();
  21. int snakeLength = input.Length;
  22.  
  23. var matrix = new string[rows, cols];
  24. var queue = new Queue<char>(input);
  25.  
  26.  
  27. for (int i = 0; i < rows; i++)
  28. {
  29. for (int j = 0; j < cols; j++)
  30. {
  31. char currentSymbol = queue.Peek();
  32. matrix[i, j] = currentSymbol.ToString();
  33.  
  34. queue.Enqueue(queue.Dequeue());
  35.  
  36. }
  37. }
  38.  
  39. for (int row = 0; row < rows; row++)
  40. {
  41. for (int col = 0; col < cols; col++)
  42. {
  43. Console.Write(matrix[row,col]);
  44. }
  45. Console.WriteLine();
  46. }
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement