Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace TechFundamentalsExam
  5. {
  6.     public sealed class Startup
  7.     {
  8.         private static void Main(string[] args)
  9.         {
  10.             int[] dimensions = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.             int[,] garden = new int[dimensions[0], dimensions[1]];
  12.             string input = Console.ReadLine();
  13.  
  14.             while (input != "Bloom Bloom Plow")
  15.             {
  16.                 int[] tokens = input.Split(' ').Select(int.Parse).ToArray();
  17.                 int row = tokens[0];
  18.                 int col = tokens[1];
  19.  
  20.                 for (int r = 0; r < garden.GetLength(0); r++)
  21.                 {
  22.                     garden[r, col]++;
  23.                 }
  24.  
  25.                 for (int c = 0; c < garden.GetLength(1); c++)
  26.                 {
  27.                     garden[row, c]++;
  28.                 }
  29.  
  30.                 garden[row, col]--;
  31.  
  32.                 input = Console.ReadLine();
  33.             }
  34.  
  35.             for (int row = 0; row < garden.GetLength(0); row++)
  36.             {
  37.                 for (int col = 0; col < garden.GetLength(1); col++)
  38.                 {
  39.                     Console.Write($"{garden[row, col]} ");
  40.                 }
  41.  
  42.                 Console.WriteLine();
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement