Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel.DataAnnotations.Schema;
- using System.Linq;
- namespace Garden
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] dimensionsInput = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int rows = dimensionsInput[0];
- int cols = dimensionsInput[1];
- int[,] garden = new int[rows, cols];
- string command = Console.ReadLine();
- while (command != "Bloom Bloom Plow")
- {
- int[] blooming = command.Split().Select(int.Parse).ToArray();
- int currentRow = blooming[0];
- int currentCol = blooming[1];
- if ((currentRow < 0 || currentRow > rows - 1)
- || (currentCol < 0 || currentCol > cols - 1))
- {
- Console.WriteLine("Invalid coordinates.");
- continue;
- }
- garden[currentRow, currentCol] = 1;
- for (int col = 0; col < cols; col++)
- {
- if (garden[currentRow, col] == 1)
- {
- garden[currentRow, col] = 2;
- }
- else
- {
- garden[currentRow, col] = 1;
- }
- }
- for (int row = 0; row < rows; row++)
- {
- if (garden[row, currentCol] == 1)
- {
- garden[row, currentCol] = 2;
- }
- else
- {
- garden[row, currentCol] = 1;
- }
- }
- command = Console.ReadLine();
- }
- PrintGarden(rows, cols, garden);
- }
- private static void PrintGarden(int rows, int cols, int[,] garden)
- {
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- Console.Write(garden[row, col] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment