Advertisement
valchak

Generate rectangle new2

Feb 25th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 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 Exercise_12_Generate_rectan
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int n = int.Parse(Console.ReadLine());
  15.             int m = int.Parse(Console.ReadLine());
  16.  
  17.             int areaRectangle;
  18.             int cnt = 0;
  19.  
  20.             if (n < 1)
  21.             {
  22.                 Console.WriteLine("No");
  23.                 return;
  24.             }
  25.  
  26.             for (int x1 = -n; x1 <= 0; x1++)
  27.             {
  28.                 for (int y1 = -n; y1 <= 0; y1++)
  29.                 {
  30.                     for (int x2 = x1+1; x2 <= n; x2++)
  31.                     {
  32.                         for (int y2 = y1+1; y2 <= n; y2++)
  33.                         {
  34.                                 areaRectangle = (x2 - x1) * (y2 - y1);
  35.  
  36.                             if (areaRectangle >= m)
  37.                             {
  38.                                 Console.Write("({0}, {1}) ({2}, {3}) -> {4}",
  39.                                 x1, y1, x2, y2, areaRectangle);
  40.  
  41.                                 Console.WriteLine();
  42.                                 cnt++;
  43.                             }
  44.  
  45.                         }
  46.                     }
  47.                 }
  48.  
  49.             }
  50.  
  51.             if (cnt == 0)
  52.             {
  53.                 Console.WriteLine("No");
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement