-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLargestAreaTriangle.java
More file actions
28 lines (26 loc) · 885 Bytes
/
LargestAreaTriangle.java
File metadata and controls
28 lines (26 loc) · 885 Bytes
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
import java.util.Arrays;
public class LargestAreaTriangle {
public static void main(String[] args) {
// int[][] points = {{0, 0}, {0, 1}, {1, 0}, {0, 2}, {2, 0}};
// int[][] points = {{1,0},{0,0},{0,1}};
int[][] points={{4,6},{6,5},{3,1}};
System.out.println(largestTriangleAreaSoulution(points));
}
static double largestTriangleAreaSoulution(int[][] points) {
int largestSideOne = 0;
int largestSideTwo = 0;
for (int i=0;i<points.length;i++){
if(points[i][0]>largestSideOne){
largestSideOne=points[i][0];
}
if(points[i][0]>largestSideTwo){
largestSideTwo=points[i][0];
}
}
System.out.println(largestSideOne);
System.out.println(largestSideTwo);
double answer = (largestSideOne*largestSideTwo)*0.5;
// System.out.println("answer"+answer);
return answer;
}
}