[알고리즘] 최대수 구하기
2023. 12. 31. 22:59ㆍ알고리즘 풀이/Java
나의 풀이
- Integer.MIN_VALUE를 배웠다.
- nextInt()를 하게 되면 스페이스와 개행을 제외하고 숫자를 입력받는다.
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
int maxNumber = Integer.MIN_VALUE;
for(int i = 0; i < 10; i++) {
int curNumber = sc.nextInt();
if (maxNumber < curNumber) {
maxNumber = curNumber;
}
}
System.out.println("#" + test_case + " " + maxNumber);
}
}
}
'알고리즘 풀이 > Java' 카테고리의 다른 글
[알고리즘] 파리퇴치3 (1) | 2024.01.01 |
---|---|
[알고리즘] 자릿수 더하기 (0) | 2023.12.31 |
[알고리즘] 중간값 찾기 (0) | 2023.12.31 |
[알고리즘] 1대1 가위바위보 (1) | 2023.12.31 |
[알고리즘] 홀수만 더하기 (0) | 2023.12.31 |