aggressiveviking

12.GenerateRectangles

Mar 5th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _12.GenerateRectangles
  4. {
  5.     class GenerateRectangles
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int m = int.Parse(Console.ReadLine());
  11.  
  12.             int count = 0;
  13.             int area = 0;
  14.  
  15.             for (int left = -n; left < n; left++)
  16.             {
  17.                 for (int top = -n; top < n; top++)
  18.                 {
  19.                     for (int right = left + 1; right <= n; right++)
  20.                     {
  21.                         for (int bottom = top + 1; bottom <= n; bottom++)
  22.                         {
  23.                             area = Math.Abs(right - left) * Math.Abs(bottom - top);
  24.  
  25.                             if (area >= m)
  26.                             {
  27.                                 Console.WriteLine($"({left}, {top}) ({right}, {bottom}) -> {area}");
  28.  
  29.                                 count++;
  30.                             }
  31.                         }
  32.                     }
  33.                 }
  34.             }
  35.  
  36.             if (count == 0)
  37.             {
  38.                 Console.WriteLine("No");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment