[알고리즘] 최대수 구하기

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);

		}
	}
}

 

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QQhbqA4QDFAUq&categoryId=AV5QQhbqA4QDFAUq&categoryType=CODE&problemTitle=2068&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

'알고리즘 풀이 > Java' 카테고리의 다른 글

[알고리즘] 파리퇴치3  (1) 2024.01.01
[알고리즘] 자릿수 더하기  (0) 2023.12.31
[알고리즘] 중간값 찾기  (0) 2023.12.31
[알고리즘] 1대1 가위바위보  (1) 2023.12.31
[알고리즘] 홀수만 더하기  (0) 2023.12.31