Advertisement
pifka

Snake Moves

May 12th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Numerics;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9.  
  10. namespace solutions
  11. {
  12. class Program
  13. {
  14. public static void Main()
  15. {
  16. var matrixSize = Console.ReadLine().Split().Select(int.Parse).ToArray();
  17. var snake = Console.ReadLine();
  18.  
  19. var rows = matrixSize[0];
  20. var cols = matrixSize[1];
  21. var matrix = new char[rows, cols];
  22. var counter = 0;
  23.  
  24. for (int row = 0; row < rows; row++)
  25. {
  26. for (int col = 0; col < cols; col++)
  27. {
  28. if (counter == snake.Length)
  29. {
  30. counter = 0;
  31. }
  32.  
  33. matrix[row, col] = snake[counter];
  34. counter++;
  35. }
  36. }
  37. for (int row = 0; row < rows; row++)
  38. {
  39. for (int col = 0; col < cols; col++)
  40. {
  41. Console.Write(matrix[row, col]);
  42. }
  43. Console.WriteLine();
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement