Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BasicsExamDec
- {
- using System;
- using System.Linq;
- public sealed class Exam
- {
- static void Main(string[] args)
- {
- int[] dimensions = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- string word = Console.ReadLine();
- int[] shotPareameters = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- char[,] matrix = new char[dimensions[0], dimensions[1]];
- int impactRow = shotPareameters[0];
- int impactCol = shotPareameters[1];
- int radius = shotPareameters[2];
- int index = 0;
- int checker = 0;
- for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
- {
- checker++;
- if (checker % 2 == 0)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- matrix[row, col] = word[index];
- index++;
- if (index == word.Length)
- {
- index = 0;
- }
- }
- }
- else
- {
- for (int col = matrix.GetLength(1) - 1; col >= 0; col--)
- {
- matrix[row, col] = word[index];
- index++;
- if (index == word.Length)
- {
- index = 0;
- }
- }
- }
- }
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- bool isInImpactZone =
- (row - impactRow) * (row - impactRow) + (col - impactCol) * (col - impactCol) <= radius * radius;
- if (isInImpactZone)
- {
- matrix[row, col] = ' ';
- }
- }
- }
- bool isFallen = false;
- do
- {
- isFallen = false;
- for (int row = 0; row < matrix.GetLength(0) - 1; row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- if (matrix[row,col] != ' ' && matrix[row+1, col]==' ')
- {
- matrix[row + 1, col] = matrix[row, col];
- matrix[row, col] = ' ';
- isFallen = true;
- }
- }
- }
- } while (isFallen);
- for (int r = 0; r < matrix.GetLength(0); r++)
- {
- for (int c = 0; c < matrix.GetLength(1); c++)
- {
- Console.Write(matrix[r, c]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement