https://www.acmicpc.net/problem/10818
10818번: 최소, 최대
첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다.
www.acmicpc.net
class 1++ 까지 채우고 싶어 풀게 되었다.
배열의 최솟값, 최댓값은 Min, Max로 구할 수 있다.
using System;
using System.Text;
namespace B10818
{
class Program
{
static void Main()
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
StringBuilder sb = new StringBuilder();
int n = int.Parse(sr.ReadLine());
int[] array = Array.ConvertAll(sr.ReadLine().Split(' '), int.Parse);
sb.Append(array.Min());
sb.Append(' ');
sb.Append(array.Max());
sw.Write(sb);
sr.Close();
sw.Flush();
sw.Close();
}
}
}
'알고리즘 > 백준 BOJ' 카테고리의 다른 글
[ BOJ/C# ] 11047 동전 0 (0) | 2023.09.15 |
---|---|
[ BOJ/C# ] 2577 숫자의 개수 (0) | 2023.09.14 |
[ BOJ/C# ] 1929 소수 구하기 _ 에라토스테네스의 체 (0) | 2023.09.11 |
[ BOJ/C# ] 1978 소수 찾기 (0) | 2023.09.10 |
[ BOJ/C# ] 1620 나는야 포켓몬 마스터 이다솜 (0) | 2023.09.09 |