LardaX

Generate_Rectangles_Two

Aug 22nd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Generate_Rectangles
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int point = int.Parse(Console.ReadLine());
  14.             int minArea = int.Parse(Console.ReadLine());
  15.             int counter = 0;
  16.  
  17.             for (int left = -point; left < point; left++)
  18.             {
  19.                 for (int top = -point; top < point; top++)
  20.                 {
  21.                     for (int right = left; right <= point; right++)
  22.                     {
  23.                         for (int bottom = top; bottom <= point; bottom++)
  24.                         {
  25.                             int leftRightSide = bottom - top;
  26.                             int topBottomSide = right - left;
  27.                             int area = leftRightSide * topBottomSide;
  28.                             if (area >= minArea)
  29.                             {
  30.                                 Console.WriteLine("({0}, {1}) ({2}, {3}) -> {4}", left, top, right, bottom, area);
  31.                                 counter++;
  32.                             }
  33.                         }
  34.                     }
  35.                 }
  36.             }
  37.             if (counter == 0)
  38.             {
  39.                 Console.WriteLine("No");
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment