Advertisement
valchak

Generate rectangle new2

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