알고리즘 - 백준, 10818번 최소,최대

jodbsgh·2022년 12월 22일
0


import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		int n = Integer.parseInt(br.readLine());
		
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        
		int tmp = Integer.parseInt(st.nextToken());
		
		int max = tmp;
        int min = tmp;
        
        String result;
        while(st.hasMoreTokens()){
            tmp = Integer.parseInt(st.nextToken());
            if(tmp> max){
                max = tmp;   
            }else if(tmp<min){
                min = tmp;
            }
        }
        
       // result = sb.append(min).append(" ").append(max).toString() ;
       
        System.out.print(min + " " + max);
        
    }
}

 

자 드가자~

profile
어제 보다는 내일을, 내일 보다는 오늘을 🚀

0개의 댓글