Advertisement
Tanina80

12.GenerateRectangles 90/100

Jul 17th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace RectangleWithStars
  5. {
  6. class RectangleWithStars
  7. {
  8. static void Main(string[] args)
  9. {
  10. uint n = uint.Parse(Console.ReadLine());
  11. int area = int.Parse(Console.ReadLine());
  12. var n1 = -1 * n;
  13.  
  14. bool found = false;
  15.  
  16. for (var x1 = n1; x1 <= n; x1++)
  17. {
  18. for (var x2 = n1; x2 <= n; x2++)
  19.  
  20. {
  21. for (var y1 = n1; y1 <= n; y1++)
  22. {
  23. for (var y2 = n1; y2 <= n; y2++)
  24. {
  25. //var area1 = Math.Abs(x2 - x1) * Math.Abs(y2 - y1);
  26.  
  27. if (n1 <= x1 && x1 < x2 && x2 <= n && n1 <= y1 && y1 < y2 && y2 <= n)
  28. {
  29. var area1 = Math.Abs(x2 - x1) * Math.Abs(y2 - y1);
  30. if (area1 >= area)
  31. {
  32. found = true;
  33. Console.WriteLine("({0}, {1}) ({2}, {3}) -> {4}", x1, y1, x2, y2, area1);
  34. }
  35.  
  36. }
  37.  
  38. }
  39.  
  40.  
  41. }
  42. }
  43. }
  44. if (found == false)
  45. {
  46. Console.WriteLine("No");
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement