Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _5._Snake_Moves
- {
- class StartUp
- {
- static void Main(string[] args)
- {
- var dimensions = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- int rows = dimensions[0];
- int cols = dimensions[1];
- var matrix = new char[rows, cols];
- string snake = Console.ReadLine();
- int index = 0;
- for (int row = 0; row < rows; row++)
- {
- var curRow = new List<char>();
- while(curRow.Count <= rows)
- {
- curRow.Add(snake[index]);
- index++;
- if (index > cols)
- {
- index = 0;
- }
- }
- if (row % 2 == 1)
- {
- curRow.Reverse();
- }
- for (int col = 0; col < cols; col++)
- {
- matrix[row, col] = curRow[col];
- }
- }
- 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