백준 9063번
import java.util.Arrays;
import java.util.Scanner;
public class problem456 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = in.nextInt();
int[] xArr = new int[size];
int[] yArr = new int[size];
if (size != 1) {
for (int i = 0; i < size; i++) {
xArr[i] = in.nextInt();
yArr[i] = in.nextInt();
}
}
Arrays.sort(xArr);
Arrays.sort(yArr);
System.out.println((xArr[0] - xArr[size - 1]) *
(yArr[0] - yArr[size - 1]));
}
}
백준 5073번
import java.util.Scanner;
public class problem457 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
// 탈출 조건
if (a == 0 && b == 0 && c == 0) {
break;
}
// 가장 긴 변 구하기
int maxLength = Math.max(a, Math.max(b, c));
// 삼각형 조건 검증
if(maxLength < a + b + c - maxLength){
if (a == b && b == c) {
System.out.println("Equilateral");
}
// 두개의 변만 같은 경우
else if(a == b || b == c || a == c){
System.out.println("Isosceles");
}else{
System.out.println("Scalene");
}
}else{
System.out.println("Invalid");
}
}
}
}
백준 14215번
import java.util.Scanner;
public class problem458 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] size = new int[3];
for (int i = 0; i < size.length; i++) {
size[i] = in.nextInt();
}
// 오름차순 정렬
for (int i = 0; i < size.length; i++) {
for (int j = i + 1; j < size.length; j++) {
if (size[i] > size[j]) {
int temp = size[i];
size[i] = size[j];
size[j] = temp;
}
}
}
// 3개의 값이 삼각형이 될경우
if (size[0] + size[1] > size[2]) {
System.out.println(size[0] + size[1] + size[2]);
}
// 길이 조절
else {
System.out.println((size[1] + size[0]) * 2 - 1);
}
}
}