-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriunghiuri.java
More file actions
33 lines (32 loc) · 1.22 KB
/
Triunghiuri.java
File metadata and controls
33 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public class Triunghi{
double a,b,c,raport;
Triunghi(double a, double b, double c){
if((Math.max(Math.max(a,b),c)<(a+b+c)-Math.max(Math.max(a,b),c))&&(a!=b)&&(b!=c)&&Math.pow(Math.max(Math.max(a,b),c),2)!=Math.pow((a+b+c)-Math.max(Math.max(a,b),c)-Math.min(Math.min(a,b),c),2)+Math.pow(Math.min(Math.min(a,b),c),2)){
this.a=a;
this.b=b;
this.c=c;
}
}
void setRaport(){
double arie=Math.sqrt(((this.a+this.b+this.c)/2)*(((this.a+this.b+this.c)/2)-this.a)*(((this.a+this.b+this.c)/2)-this.b)*(((this.a+this.b+this.c)/2)-this.c));
double perimetru=this.a+this.b+this.c;
this.raport=arie/perimetru;
}
}
import java.util.*;
public class ECCPR{
public static void main(String []args){
double max=0;
int index=0;
int n;
Scanner sc= new Scanner(System.in);
n= sc.nextInt();
for(int i=0;i<n;i++){
Triunghi tr= new Triunghi(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
tr.setRaport();
max=(tr.raport>max)?tr.raport:max;
index=(tr.raport>=max)?i:index;
}
System.out.printf("%d %.3f",(int)index,max);
}
}