Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace SnakeMoves
- {
- class Program
- {
- static void Main(string[] args)
- {
- var matrixDimension = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- int rows = matrixDimension[0];
- int cols = matrixDimension[1];
- var snakeMatrix = new char[rows, cols];
- string snake = Console.ReadLine();
- int counter = 0;
- for (int row = 0; row < snakeMatrix.GetLength(0); row++)
- {
- if (row % 2 == 0 )
- {
- for (int col = 0; col < snakeMatrix.GetLength(1); col++)
- {
- snakeMatrix[row, col] = snake[counter++];
- if (counter == snake.Length)
- {
- counter = 0;
- }
- } // for za koloni
- } // if za chetni koloni
- else
- {
- for (int col = snakeMatrix.GetLength(1) - 1; col >= 0; col--)
- {
- snakeMatrix[row, col] = snake[counter++];
- if (counter == snake.Length)
- {
- counter = 0;
- }
- }// for za koloni
- } // else za nechetni koloni
- }
- for (int row = 0; row < snakeMatrix.GetLength(0); row++)
- {
- for (int col = 0; col < snakeMatrix.GetLength(1); col++)
- {
- Console.Write(snakeMatrix[row, col]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement