LardaX

Generate_Rectangles

Aug 22nd, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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 = -point; right <= point; right++)
  22.                     {
  23.                         for (int bottom = -point; bottom <= point; bottom++)
  24.                         {
  25.                             if (bottom > top && right > left)
  26.                             {
  27.                                 int leftRightSide = bottom - top;
  28.                                 int topBottomSide = right - left;
  29.                                 int area = leftRightSide * topBottomSide;
  30.                                 if (area >= minArea)
  31.                                 {
  32.                                     Console.WriteLine("({0}, {1}) ({2}, {3}) -> {4}", left, top, right, bottom, area );
  33.                                     counter++;
  34.                                 }
  35.                             }
  36.                         }
  37.                     }
  38.                 }
  39.             }
  40.             if (counter == 0)
  41.             {
  42.                 Console.WriteLine("No");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment