알고리즘/백준 BOJ
[ BOJ/C# ] 10818 최소, 최대
왹져박사
2023. 9. 13. 00:01
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();
}
}
}