출제 링크 : https://www.acmicpc.net/problem/10818
10818번: 최소, 최대
첫째 줄에 정수의 개수 N (1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 N개의 정수를 공백으로 구분해서 주어진다. 모든 정수는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다.
www.acmicpc.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Solution
{
class Program
{
static void Main(string[] args)
{
//Min에 int형 최고의 값을 넣어 처음받는 값을 무조건 Min에 넣도록 했다.
int Min = int.MaxValue;
int Max = int.MinValue;
int numbers = int.Parse(Console.ReadLine());
string[] Num_List = Console.ReadLine().Split(' ');
for (int i = 0; i < numbers; i++)
{
int temp = int.Parse(Num_List[i]);
if (temp < Min)
{
Min = temp;
}
if (Max < temp)
{
Max = temp;
}
}
Console.WriteLine($"{Min} {Max}");
}
}
}
'Baekjoon 문제풀이' 카테고리의 다른 글
[Baekjoon 5단계(2)] 2577번 : 숫자의 개수 (0) | 2021.09.02 |
---|---|
[Baekjoon 5단계(2)] 2562번 : 최댓값 (0) | 2021.09.02 |
[Baekjoon 4단계(3)] 1110번 : 더하기 사이클 (0) | 2021.09.01 |
[Baekjoon 4단계(2)] 10951번 : A+B - 4 (0) | 2021.09.01 |
[Baekjoon 4단계(1)] 10952번 : A+B - 5 (0) | 2021.08.31 |