Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02.Nature_s_Prophet
- {
- public class NaturesProphet
- {
- public static void Main()
- {
- int[] sizes = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int[][] matrix = new int[sizes[0]][];
- for (int row = 0; row < matrix.Length; row++)
- {
- matrix[row] = new int[sizes[1]];
- }
- string line = Console.ReadLine();
- while (line != "Bloom Bloom Plow")
- {
- var tokens = line.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
- int currentRow = int.Parse(tokens[0]);
- int currentCol = int.Parse(tokens[1]);
- for (int row = currentRow; row <= currentRow; row++)
- {
- for (int col = currentCol; col < matrix[row].Length; col++)
- {
- if (IsInRange(matrix, row, col))
- {
- matrix[row][col]++;
- }
- }
- for (int col = currentCol - 1; col >= 0; col--)
- {
- if (IsInRange(matrix, row, col))
- {
- matrix[row][col]++;
- }
- }
- }
- for (int col = currentCol; col <= currentCol; col++)
- {
- for (int row = currentRow + 1; row < matrix.Length; row++)
- {
- if (IsInRange(matrix, row, col))
- {
- matrix[row][col]++;
- }
- }
- for (int row = currentRow - 1; row >= 0; row--)
- {
- if (IsInRange(matrix, row, col))
- {
- matrix[row][col]++;
- }
- }
- }
- line = Console.ReadLine();
- }
- for (int row = 0; row < matrix.Length; row++)
- {
- for (int col = 0; col < matrix[row].Length; col++)
- {
- Console.Write(matrix[row][col] + " ");
- }
- Console.WriteLine();
- }
- }
- public static bool IsInRange(int[][] matrix, int row, int col)
- {
- if (row < matrix.Length && col < matrix[row].Length)
- {
- return true;
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment