Description
给出两个三角形的三条边,判断是否相似。
Input
多组数据,给出6正个整数,a1,b1,c1,a2,b2,c2,分别代表两个三角形。(边长小于100且无序)
Output
如果相似输出YES,如果不相似输出NO,如果三边组不成三角形也输出NO。
Sample
Input
1 2 3 2 4 6
3 4 5 6 8 10
3 4 5 7 8 10
Output
NO
YES
NO
import java.util.Scanner;
class San {
double a,b,c;
public San(double a[]) {
super();
double max=a[0],min=a[0],mid=a[0];
for(int i=1;i<3;i++) {
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
for(int i=0;i<3;i++)
if(a[i]!=min&&a[i]!=max)
mid=a[i];
this.a=max;
this.b=mid;
this.c=min;
}
public boolean judge(San x,San y) {
if(x.b+x.c<=x.a&&y.b+y.c<=y.a)
return false;
if(x.a>y.a) {
if(x.a/y.a==x.b/y.b&&x.a/y.a==x.c/y.c)
return true;
else
return false;
}
else {
if(y.a/x.a==y.b/x.b&&y.a/x.a==y.c/x.c)
return true;
else
return false;
}
}
}
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double x[] = new double[3];
double y[] = new double[3];
while(input.hasNext()) {
for(int i=0;i<3;i++)
x[i]=input.nextInt();
San s1 = new San(x);
for(int i=0;i<3;i++)
y[i]=input.nextInt();
San s2 = new San(y);
San judge = new San();
if(judge.judge(s1, s2))
System.out.println("YES");
else
System.out.println("NO");
}
input.close();
}
}