[java]
public class Intersect {
public void main(String args[]) {
}
public int area(int[] x, int[] y) {
if(x.length % 2 == 1 || y.length %2 == 1 || x.length != y.length)
return 0;
int Xmax=10000, Xmin=-10000;
int Ymax=10000, Ymin=-10000;
for(int i=0; i
int xmin = Math.min(x[i], x[i+1]);
Xmax = Math.min(Xmax, xmax);
Xmin = Math.max(Xmin, xmin);
}
for(int i=0; i
int ymin = Math.min(y[i], y[i+1]);
Ymax = Math.min(ymax, ymax);
Ymin = Math.max(ymin, ymin);
}
int area = 0;
area = (Xmax - Xmin) * (Ymax - Ymin);
return area >= 0 ? area : 0;
}
}
[/java]
0 件のコメント:
コメントを投稿