BorislavBorisov

08.03.Teleport points мое

Feb 27th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class TeleportPoints
  4. {
  5.     static void Main()
  6.     {
  7.         string input = "";
  8.         for (int i = 0; i < 4; i++)
  9.         {
  10.             input += Console.ReadLine();
  11.             input += " ";
  12.         }
  13.         string[] allPoints = input.Split(' ');
  14.         double r = double.Parse(Console.ReadLine());
  15.         double step = double.Parse(Console.ReadLine());
  16.  
  17.         double XA = double.Parse(allPoints[0]);//тези не трябва да се парсват в цикъл, защото имаме едно обхождане
  18.         double YA = double.Parse(allPoints[1]);
  19.         double XB = double.Parse(allPoints[2]);
  20.         double YB = double.Parse(allPoints[3]);
  21.         double XC = double.Parse(allPoints[4]);
  22.         double YC = double.Parse(allPoints[5]);
  23.         double XD = double.Parse(allPoints[6]);
  24.         double YD = double.Parse(allPoints[7]);
  25.  
  26.         int counter = 0;
  27.  
  28.         for (double x = 0; x <= r; x += step)
  29.         {
  30.             for (double y = 0; y <= r; y += step)
  31.             {
  32.                 if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
  33.                 {
  34.                     if ((x > XA && x < XB) && (y > YA && y < YC))
  35.                     {
  36.                         counter++;
  37.                     }
  38.                 }
  39.             }
  40.             for (double y = -step; y >= -r; y -= step)
  41.             {
  42.                 if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
  43.                 {
  44.  
  45.                     if ((x > XA && x < XB) && (y > YA && y < YC))
  46.                     {
  47.                         counter++;
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.         for (double x = -step; x >= -r; x -= step)
  53.         {
  54.             for (double y = 0; y <= r; y += step)
  55.             {
  56.                 if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
  57.                 {
  58.  
  59.                     if ((x > XA && x < XB) && (y > YA && y < YC))
  60.                     {
  61.                         counter++;
  62.                     }
  63.                 }
  64.             }
  65.             for (double y = -step; y >= -r; y -= step)
  66.             {
  67.                 if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
  68.                 {
  69.  
  70.                     if ((x > XA && x < XB) && (y > YA && y < YC))
  71.                     {
  72.                         counter++;
  73.                     }
  74.                 }
  75.             }
  76.         }
  77.         Console.WriteLine(counter);
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment