Advertisement
silvana1303

garden

Oct 25th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.22 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4.  
  5. namespace BookWorm
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             /*int[,] matrix = new int[5, 5];
  12.  
  13.             for (int i = 0; i < 5; i++)
  14.             {
  15.                 for (int j = 0; j < 5; j++)
  16.                 {
  17.                     matrix[i, j] = 0;
  18.                 }
  19.             }
  20.  
  21.             for (int i = 0; i < 5; i++)
  22.             {
  23.                 for (int j = 0; j < 5; j++)
  24.                 {
  25.                     Console.Write(matrix[i, j]);
  26.  
  27.                 }
  28.  
  29.                 Console.WriteLine();
  30.             }*/
  31.  
  32.  
  33.             int[] rowCow = Console.ReadLine().Split().Select(int.Parse).ToArray();
  34.             int row = 0;
  35.             int col = 0;
  36.  
  37.             row = rowCow[0];
  38.             col = rowCow[1];
  39.  
  40.             int[,] matrix = new int[row,col];
  41.  
  42.             for (int i = 0; i < row; i++)
  43.             {
  44.                 for (int j = 0; j < col; j++)
  45.                 {
  46.                     matrix[i, j] = 0;
  47.                 }
  48.             }
  49.  
  50.             string command = Console.ReadLine();
  51.  
  52.             while (command != "Bloom Bloom Plow")
  53.             {
  54.                 int[] dimensions = command.Split().Select(int.Parse).ToArray();
  55.  
  56.                 int flowerRow = 0;
  57.                 int flowerCol = 0;
  58.  
  59.                 flowerCol = dimensions[1];
  60.                 flowerRow = dimensions[0];
  61.  
  62.                 int originalRow = dimensions[0];
  63.                 int originalCol = dimensions[1];
  64.  
  65.                 if (flowerRow < 0 || flowerCol > row - 1 || flowerCol < 0 || flowerCol > row - 1)
  66.                 {
  67.                     Console.WriteLine("Invalid coordinates.");
  68.                 }
  69.                 else
  70.                 {
  71.                     /*while (flowerRow >= 0)
  72.                     {
  73.                         flowerRow--;
  74.                         matrix[flowerRow, flowerCol]++;
  75.                     }
  76.  
  77.                     while (flowerRow < row)
  78.                     {
  79.                         flowerRow++;
  80.                         matrix[flowerRow, flowerCol]++;
  81.                     }
  82.  
  83.                     while (flowerCol >= 0)
  84.                     {
  85.                         flowerCol--;
  86.                         matrix[flowerRow, flowerCol]++;
  87.                     }
  88.  
  89.                     while (flowerCol < row)
  90.                     {
  91.                         flowerCol++;
  92.                         matrix[flowerRow, flowerCol]++;
  93.                     }*/
  94.  
  95.  
  96.                     for (int i = 0; i < row; i++)
  97.                     {
  98.                         matrix[i, flowerCol]++;
  99.                     }
  100.  
  101.                     for (int i = 0; i < row; i++)
  102.                     {
  103.  
  104.                         matrix[flowerRow, i]++;
  105.                     }
  106.  
  107.                     matrix[originalRow, originalCol]--;
  108.  
  109.                 }
  110.  
  111.  
  112.  
  113.                 command = Console.ReadLine();
  114.             }
  115.  
  116.  
  117.             for (int i = 0; i < row; i++)
  118.             {
  119.                 for (int j = 0; j < row; j++)
  120.                 {
  121.                     Console.Write($"{matrix[i, j]} ");
  122.  
  123.                 }
  124.  
  125.                 Console.WriteLine();
  126.             }
  127.  
  128.         }
  129.  
  130.  
  131.     }
  132.  
  133. }
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement