fbinnzhivko

04.01 Teleport Points

Apr 15th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class TeleportPoints
  4.     {
  5.         static void Main()
  6.         {
  7.             string[] pointA = Console.ReadLine().Split(' ').ToArray();
  8.             string[] pointB = Console.ReadLine().Split(' ').ToArray();
  9.             string[] pointC = Console.ReadLine().Split(' ').ToArray();
  10.             string[] pointD = Console.ReadLine().Split(' ').ToArray();
  11.  
  12.             double radius = double.Parse(Console.ReadLine());
  13.             double step = double.Parse(Console.ReadLine());
  14.  
  15.             double aX = double.Parse(pointA[0]);
  16.             double aY = double.Parse(pointA[1]);
  17.             double bX = double.Parse(pointB[0]);
  18.             double bY = double.Parse(pointB[1]);
  19.             double cX = double.Parse(pointC[0]);
  20.             double cY = double.Parse(pointC[1]);
  21.             double dX = double.Parse(pointD[0]);
  22.             double dY = double.Parse(pointD[1]);
  23.  
  24.             int pointCounter = 0;
  25.            
  26.             for (double x = 0; x <= radius; x += step)
  27.             {
  28.                 for (double y = 0; y <= radius; y += step)
  29.                 {
  30.                     if ((Math.Pow(x - 0, 2) + Math.Pow(y - 0, 2)) <= Math.Pow(radius, 2))
  31.                     {
  32.                         if ((x > aX && x < bX) && (y < cY && y > bY))
  33.                         {
  34.                             pointCounter++;
  35.                         }
  36.                     }
  37.                 }
  38.                 for (double y = -step; y >= -radius; y -= step)
  39.                 {
  40.                     if ((Math.Pow(x - 0, 2) + Math.Pow(y - 0, 2)) <= Math.Pow(radius, 2))
  41.                     {
  42.                         if ((x > aX && x < bX) && (y < cY && y > bY))
  43.                         {
  44.                             pointCounter++;
  45.                         }
  46.                     }
  47.                 }
  48.  
  49.             }
  50.             for (double x = -step; x >= -radius; x -= step)
  51.             {
  52.                 for (double y = 0; y <= radius; y += step)
  53.                 {
  54.                     if ((Math.Pow(x - 0, 2) + Math.Pow(y - 0, 2)) <= Math.Pow(radius, 2))
  55.                     {
  56.                         if ((x > aX && x < bX) && (y < cY && y > bY))
  57.                         {
  58.                             pointCounter++;
  59.                         }
  60.                     }
  61.                 }
  62.                 for (double y = -step; y >= -radius; y -= step)
  63.                 {
  64.                     if ((Math.Pow(x - 0, 2) + Math.Pow(y - 0, 2)) <= Math.Pow(radius, 2))
  65.                     {
  66.                         if ((x > aX && x < bX) && (y < cY && y > bY))
  67.                         {
  68.                             pointCounter++;
  69.                         }
  70.                     }
  71.                 }
  72.             }
  73.             Console.WriteLine(pointCounter);
  74.         }
  75.     }
Add Comment
Please, Sign In to add comment