Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class TeleportPoints
- {
- static void Main()
- {
- string input = "";
- for (int i = 0; i < 4; i++)
- {
- input += Console.ReadLine();
- input += " ";
- }
- string[] allPoints = input.Split(' ');
- double r = double.Parse(Console.ReadLine());
- double step = double.Parse(Console.ReadLine());
- double XA = double.Parse(allPoints[0]);//тези не трябва да се парсват в цикъл, защото имаме едно обхождане
- double YA = double.Parse(allPoints[1]);
- double XB = double.Parse(allPoints[2]);
- double YB = double.Parse(allPoints[3]);
- double XC = double.Parse(allPoints[4]);
- double YC = double.Parse(allPoints[5]);
- double XD = double.Parse(allPoints[6]);
- double YD = double.Parse(allPoints[7]);
- int counter = 0;
- for (double x = 0; x <= r; x += step)
- {
- for (double y = 0; y <= r; y += step)
- {
- if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
- {
- if ((x > XA && x < XB) && (y > YA && y < YC))
- {
- counter++;
- }
- }
- }
- for (double y = -step; y >= -r; y -= step)
- {
- if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
- {
- if ((x > XA && x < XB) && (y > YA && y < YC))
- {
- counter++;
- }
- }
- }
- }
- for (double x = -step; x >= -r; x -= step)
- {
- for (double y = 0; y <= r; y += step)
- {
- if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
- {
- if ((x > XA && x < XB) && (y > YA && y < YC))
- {
- counter++;
- }
- }
- }
- for (double y = -step; y >= -r; y -= step)
- {
- if ((Math.Pow(x, 2) + Math.Pow(y, 2)) <= Math.Pow(r, 2))
- {
- if ((x > XA && x < XB) && (y > YA && y < YC))
- {
- counter++;
- }
- }
- }
- }
- Console.WriteLine(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment