标签:
1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 9 System.out.print("Enter circle1‘s center x-, y-coordinates, and radius: "); 10 double x1 = input.nextDouble(); 11 double y1 = input.nextDouble(); 12 double r1 = input.nextDouble(); 13 14 System.out.print("Enter circle2‘s center x-, y-coordinates, and radius: "); 15 double x2 = input.nextDouble(); 16 double y2 = input.nextDouble(); 17 double r2 = input.nextDouble(); 18 19 input.close(); 20 21 double distance = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); 22 23 if(distance <= Math.abs(r1 - r2)) 24 System.out.println("circle2 is inside circle1"); 25 else if(distance <= r1 + r2) 26 System.out.println("circle2 overlaps circle1"); 27 else if(distance > r1 + r2) 28 System.out.println("circle2 does not overlap circle1"); 29 } 30 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5767862.html