Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _03.CirclesIntersection
- {
- class StartUp
- {
- static void Main()
- {
- int[] firstCircle = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int[] secondCircle = Console.ReadLine().Split().Select(int.Parse).ToArray();
- Circle c1 = new Circle();
- c1.Radius = firstCircle[2];
- Point c1Center = new Point();
- c1Center.x = firstCircle[0];
- c1Center.y = firstCircle[1];
- Circle c2 = new Circle();
- c2.Radius = secondCircle[2];
- Point c2Center = new Point();
- c2Center.x = secondCircle[0];
- c2Center.y = secondCircle[1];
- double distance = CalcDistance(c1Center, c2Center);
- if (Intersect(c1, c2, distance))
- {
- Console.WriteLine("Yes");
- }
- else
- {
- Console.WriteLine("No");
- }
- }
- private static double CalcDistance(Point c1Center, Point c2Center)
- {
- double distance = Math.Sqrt(Math.Pow((c1Center.x - c2Center.x), 2) + Math.Pow((c1Center.y - c2Center.y), 2));
- return distance;
- }
- static bool Intersect(Circle c1, Circle c2,double distance)
- {
- if (distance <= c1.Radius + c2.Radius)
- {
- return true;
- }
- return false;
- }
- }
- class Circle
- {
- public double Center { get; set; }
- public double Radius { get; set; }
- }
- class Point
- {
- public int x { get; set; }
- public int y { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement