Advertisement
valchak

Generate rectangle

Feb 25th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 num1 = 0; num1 >= -n; num1--)
  31.             {
  32.                 for (int num2 = 0; num2 >= -n; num2--)
  33.                 {
  34.                     for (int num3 = 0; num3 <= n; num3++)
  35.                     {
  36.                         for (int num4 = 0; num4 <= n; num4++)
  37.                         {
  38.  
  39.                             //areaRectangle = Math.Abs(num3 - num1) * Math.Abs(num4 - num2);
  40.                             areaRectangle = (num3 - num1) *(num4 - num2);
  41.  
  42.  
  43.                             if (areaRectangle >= m)
  44.                             {
  45.                                 Console.Write("({0}, {1}) ({2}, {3}) -> {4}",
  46.                                 num1, num2, num3, num4, 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.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement