/*
* 判断一个点是不是在圆内
*
*
*/
public class Demo {
public static void main(String[] args) {
//提示用户定义圆形和半径
Scanner sc = new Scanner(System.in);
//请输入圆形坐标
System.out.println("请输入圆心坐标:");
double a1 = sc.nextDouble();
double a2 = sc.nextDouble();
//请输入半径
System.out.println("请输入半径:");
double r = sc.nextDouble();
//请输入点坐标
System.out.println("请输入点坐标");
double b1 =sc.nextDouble();
double b2 =sc.nextDouble();
//求点到圆心的距离
double c =Math.pow(Math.pow(a1-b1, 2)+Math.pow(a2-b2, 2),0.5);
//判断是否在原内
if(c<r){
System.out.println("点("+b1+","+b2+")在圆内");
}else{
System.out.println("点("+b1+","+b2+")没有在圆内");
}
}
}
时间: 2024-10-26 02:37:27