1.
package Test;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.println("请输入一个点的坐标:");
Scanner sc = new Scanner(System.in);
double x = sc.nextDouble();
double y = sc.nextDouble();
System.out.println(Pan(x,y));
}
public static boolean Pan(double a,double b){
if (a <= 200 && b <= (-0.5 * a + 100)){
return true;
}
return false;
}
}
/*
请输入一个点的坐标:
200 1
false
*/
2.
package Test;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.println("请输入第一个点的坐标以及矩形的宽高:");
Scanner sc = new Scanner(System.in);
double x1 = sc.nextDouble();
double y1 = sc.nextDouble();
double w1 = sc.nextDouble();
double h1 = sc.nextDouble();
System.out.println("请输入第二个点的坐标及矩形的宽高:");
Scanner sc1 = new Scanner(System.in);
double x2 = sc1.nextDouble();
double y2 = sc1.nextDouble();
double w2 = sc1.nextDouble();
double h2 = sc1.nextDouble();
double x = x1 -x2 >=0 ? x1-x2 : x2-x1;
double y = y1-y2 >=0? y1-y2 : y2-y1;
if (x <= (w1 - w2) / 2 && y <= (h1 - h2) / 2){
System.out.println("r2 is inside r1");
}
else if (x<= (w1 + w2) / 2 && y <= (h1 + h2) / 2){
System.out.println("r2 overlaps r1");
}
else {
System.out.println("r2 does not overlap r1");
}
}
}
3.
package Test;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.println("请输入第一个圆的中心和半径:");
Scanner sc = new Scanner(System.in);
double x1 = sc.nextDouble();
double y1 = sc.nextDouble();
double b1 = sc.nextDouble();
System.out.println("请输入第二个圆的中心和半径:");
Scanner sc1 = new Scanner(System.in);
double x2 = sc1.nextDouble();
double y2 = sc1.nextDouble();
double b2 = sc1.nextDouble();
if (Math.sqrt((x1 - x2) +(y1 - y2)) <= Math.abs(b1 - b2)){
System.out.println("圆二在圆一内");
}
else if (Math.sqrt((x1 - x2