import java.util.Arrays; |
public class test { |
public static void main(String[] args) { |
float [] x1 = { 2 , 5 }; |
float [] y1 = { 1 , 3 }; |
float [] x2 = { 5 , 7 }; |
float [] y2 = { 1 , 3 }; |
if (judge(x1, y1, x2, y2)) { |
System.out.println(“两矩形相交”); |
} else System.out.println(“两矩形不相交”); |
} |
public static boolean judge( float [] x1, float [] y1, float [] x2, float [] y2) { |
if (x1[ 0 ] > x2[ 0 ]) { |
float [] temp = { 0 , 0 }; |
for ( int i = 0 ; i x2[ 0 ] && ((y1[ 0 ] >= y2[ 0 ] && y1[ 0 ] = y2[ 0 ] && y1[ 1 ] <= y2[ 1 ]))) { |
return true ; |
} |
return false ; |
} |
} |