Advertisement
valchak

Generate rectangle new1

Feb 25th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 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.  
  27.  
  28.             for (int x1 = -n; x1 <= n; x1++)
  29.             {
  30.                 for (int y1 = -n; y1 <= n; y1++)
  31.                 {
  32.                     for (int x2 = x1+1; x2 <= n; x2++)
  33.                     {
  34.                         for (int y2 = y1+1; y2 <= n; y2++)
  35.                         {
  36.  
  37.  
  38.          
  39.                                 areaRectangle = (x2 - x1) * (y2 - y1);
  40.  
  41.  
  42.                             if (areaRectangle >= m)
  43.                             {
  44.                                 Console.Write("({0}, {1}) ({2}, {3}) -> {4}",
  45.                                 x1, y1, x2, y2, areaRectangle);
  46.  
  47.                                 Console.WriteLine();
  48.                                 cnt++;
  49.                             }
  50.  
  51.                         }
  52.                     }
  53.                 }
  54.  
  55.             }
  56.  
  57.             if (cnt == 0)
  58.             {
  59.                 Console.WriteLine("No");
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement