Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- namespace BookWorm
- {
- class Program
- {
- static void Main(string[] args)
- {
- /*int[,] matrix = new int[5, 5];
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- matrix[i, j] = 0;
- }
- }
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- Console.Write(matrix[i, j]);
- }
- Console.WriteLine();
- }*/
- int[] rowCow = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int row = 0;
- int col = 0;
- row = rowCow[0];
- col = rowCow[1];
- int[,] matrix = new int[row,col];
- for (int i = 0; i < row; i++)
- {
- for (int j = 0; j < col; j++)
- {
- matrix[i, j] = 0;
- }
- }
- string command = Console.ReadLine();
- while (command != "Bloom Bloom Plow")
- {
- int[] dimensions = command.Split().Select(int.Parse).ToArray();
- int flowerRow = 0;
- int flowerCol = 0;
- flowerCol = dimensions[1];
- flowerRow = dimensions[0];
- int originalRow = dimensions[0];
- int originalCol = dimensions[1];
- if (flowerRow < 0 || flowerCol > row - 1 || flowerCol < 0 || flowerCol > row - 1)
- {
- Console.WriteLine("Invalid coordinates.");
- }
- else
- {
- /*while (flowerRow >= 0)
- {
- flowerRow--;
- matrix[flowerRow, flowerCol]++;
- }
- while (flowerRow < row)
- {
- flowerRow++;
- matrix[flowerRow, flowerCol]++;
- }
- while (flowerCol >= 0)
- {
- flowerCol--;
- matrix[flowerRow, flowerCol]++;
- }
- while (flowerCol < row)
- {
- flowerCol++;
- matrix[flowerRow, flowerCol]++;
- }*/
- for (int i = 0; i < row; i++)
- {
- matrix[i, flowerCol]++;
- }
- for (int i = 0; i < row; i++)
- {
- matrix[flowerRow, i]++;
- }
- matrix[originalRow, originalCol]--;
- }
- command = Console.ReadLine();
- }
- for (int i = 0; i < row; i++)
- {
- for (int j = 0; j < row; j++)
- {
- Console.Write($"{matrix[i, j]} ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement