Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Linq;
- namespace ExamPreparation
- {
- public sealed class Startup
- {
- public static void Main()
- {
- double[] firstCoordinates = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(double.Parse)
- .ToArray();
- double[] secondCoordinates = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(double.Parse)
- .ToArray();
- Circle firstCircle = new Circle(new Point(firstCoordinates[0], firstCoordinates[1]), firstCoordinates[2]);
- Circle secondCircle = new Circle(new Point(secondCoordinates[0], secondCoordinates[1]), secondCoordinates[2]);
- double distance = CalculateDistance(firstCircle, secondCircle);
- bool doIntersect = distance <= firstCircle.Radius + secondCircle.Radius;
- if (doIntersect)
- {
- Console.WriteLine("Yes");
- }
- else
- {
- Console.WriteLine("No");
- }
- }
- private static double CalculateDistance(Circle first, Circle second)
- {
- double a = Math.Abs(first.Center.X - second.Center.X);
- double b = Math.Abs(first.Center.Y - second.Center.Y);
- double c = Math.Sqrt(a * a + b * b);
- return c;
- }
- }
- public sealed class Circle
- {
- public Circle(Point center, double radius)
- {
- this.Center = center;
- this.Radius = radius;
- }
- public Point Center { get; private set; }
- public double Radius { get; private set; }
- }
- public sealed class Point
- {
- public Point(double x, double y)
- {
- this.X = x;
- this.Y = y;
- }
- public double X { get; private set; }
- public double Y { get; private set; }
- }
- }
Add Comment
Please, Sign In to add comment