BorislavBorisov

08.02.Teleport Points moe

Oct 16th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. class TeleportPoints
  3. {
  4.     static void Main()
  5.     {
  6.         //друг вариант
  7.         string input = "";
  8.         for (int i = 0; i < 4; i++)
  9.         {
  10.             input += Console.ReadLine();
  11.             input += ' ';
  12.         }
  13.         string[] inputSplit = input.Split(' ');
  14.         double[] rectangular = new double[inputSplit.Length - 1];//трябва да е -1, за да не хване празният спеийс
  15.         for (int i = 0; i < rectangular.Length; i++)
  16.         {
  17.             //rectangular[i] = Convert.ToDouble(inputSplit[i]);
  18.             rectangular[i] = double.Parse(inputSplit[i]);
  19.         }
  20.         double R = double.Parse(Console.ReadLine());
  21.         double H = double.Parse(Console.ReadLine());
  22.         FindCoordinates(rectangular, R, H);
  23.    }
  24.     static void FindCoordinates(double[] rectangular, double R, double H)
  25.     {
  26.         int count = 0;
  27.         for (double x = 0; x <= R; x += H)
  28.         {
  29.             for (double y = 0; y <= R; y += H)
  30.             {
  31.                 if((x * x + y * y) <= R * R)
  32.                 {
  33.                     if(x > rectangular[0] && x < rectangular[4]
  34.                         && y > rectangular[1] && y < rectangular[5])
  35.                     {
  36.                         count++;
  37.                     }
  38.                 }
  39.             }
  40.             for (double y = -H; y >= -R; y -= H)
  41.             {
  42.                 if ((x * x + y * y) <= R * R)
  43.                 {
  44.                     if (x > rectangular[0] && x < rectangular[4]
  45.                         && y > rectangular[1] && y < rectangular[5])
  46.                     {
  47.                         count++;
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.         for (double x = -H; x >= -R; x -= H)
  53.         {
  54.             for (double y = 0; y <= R; y += H)
  55.             {
  56.                 if ((x * x + y * y) <= R * R)
  57.                 {
  58.                     if (x > rectangular[0] && x < rectangular[4]
  59.                         && y > rectangular[1] && y < rectangular[5])
  60.                     {
  61.                         count++;
  62.                     }
  63.                 }
  64.             }
  65.             for (double y = -H; y >= -R; y -= H)
  66.             {
  67.                 if ((x * x + y * y) <= R * R)
  68.                 {
  69.                     if (x > rectangular[0] && x < rectangular[4]
  70.                         && y > rectangular[1] && y < rectangular[5])
  71.                     {
  72.                         count++;
  73.                     }
  74.                  }
  75.             }
  76.         }
  77.         Console.WriteLine(count);
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment