Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Globalization;
  7. using System.Numerics;
  8. namespace ConsoleApp18
  9. {
  10.     class Program
  11.     {
  12.         class Circle
  13.         {
  14.  
  15.            
  16.             public int CenterPointX { get; set; }
  17.             public int CenterPointY { get; set; }
  18.             public int Radius { get; set; }
  19.  
  20.  
  21.             class Point
  22.             {
  23.                 public int X { get; set; }
  24.                 public int Y { get; set; }
  25.             }
  26.  
  27.             static bool Intersection()
  28.             {
  29.                 int[] circle1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
  30.                 int[] circle2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
  31.  
  32.  
  33.                 Point p = new Point() { X = circle1[0], Y = circle1[1] };
  34.                 Point p2 = new Point() { X = circle2[0], Y = circle2[1] };
  35.  
  36.                 int radiusalpha = circle1[2];
  37.                 int radiusbeta = circle2[2];
  38.  
  39.                 Circle alpha = new Circle() { CenterPointX = p.X, CenterPointY = p.Y, Radius = radiusalpha };
  40.                 Circle beta = new Circle() { CenterPointX = p2.X, CenterPointY = p2.Y, Radius = radiusbeta };
  41.  
  42.                 double sumofradiuses = alpha.Radius + beta.Radius;
  43.                 double Distance = Math.Sqrt(Math.Pow(alpha.CenterPointX - beta.CenterPointX, 2) + Math.Pow(alpha.CenterPointY - beta.CenterPointY, 2)); // Разстоянието се намира по Питагоровата теорема -> Math.Sqrt(a*a + b*b)
  44.  
  45.                 if (Distance > sumofradiuses) // Ако Distance == sumofradiuses, се пресичат
  46.                 {
  47.                     return false;
  48.                 }
  49.                 return true;
  50.             }
  51.             static void Main(string[] args)
  52.             {
  53.              
  54.                 if (Intersection() == true)
  55.                 {
  56.                     Console.WriteLine("Yes");
  57.                 }
  58.                 else
  59.                 {
  60.                     Console.WriteLine("No");
  61.                 }
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement