Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class TeleportPoints
- {
- static void Main()
- {
- //друг вариант
- string input = "";
- for (int i = 0; i < 4; i++)
- {
- input += Console.ReadLine();
- input += ' ';
- }
- string[] inputSplit = input.Split(' ');
- double[] rectangular = new double[inputSplit.Length - 1];//трябва да е -1, за да не хване празният спеийс
- for (int i = 0; i < rectangular.Length; i++)
- {
- //rectangular[i] = Convert.ToDouble(inputSplit[i]);
- rectangular[i] = double.Parse(inputSplit[i]);
- }
- double R = double.Parse(Console.ReadLine());
- double H = double.Parse(Console.ReadLine());
- FindCoordinates(rectangular, R, H);
- }
- static void FindCoordinates(double[] rectangular, double R, double H)
- {
- int count = 0;
- for (double x = 0; x <= R; x += H)
- {
- for (double y = 0; y <= R; y += H)
- {
- if((x * x + y * y) <= R * R)
- {
- if(x > rectangular[0] && x < rectangular[4]
- && y > rectangular[1] && y < rectangular[5])
- {
- count++;
- }
- }
- }
- for (double y = -H; y >= -R; y -= H)
- {
- if ((x * x + y * y) <= R * R)
- {
- if (x > rectangular[0] && x < rectangular[4]
- && y > rectangular[1] && y < rectangular[5])
- {
- count++;
- }
- }
- }
- }
- for (double x = -H; x >= -R; x -= H)
- {
- for (double y = 0; y <= R; y += H)
- {
- if ((x * x + y * y) <= R * R)
- {
- if (x > rectangular[0] && x < rectangular[4]
- && y > rectangular[1] && y < rectangular[5])
- {
- count++;
- }
- }
- }
- for (double y = -H; y >= -R; y -= H)
- {
- if ((x * x + y * y) <= R * R)
- {
- if (x > rectangular[0] && x < rectangular[4]
- && y > rectangular[1] && y < rectangular[5])
- {
- count++;
- }
- }
- }
- }
- Console.WriteLine(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment