https://www.acmicpc.net/problem/10818
배열 카테고리의 최소, 최대 문제 입니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _10818
{
class Program
{
static void Main(string[] args)
{
int size = int.Parse(Console.ReadLine());
string[] splitInput = Console.ReadLine().Split(' ');
List<int> intList = new List<int>();
foreach (string s in splitInput)
intList.Add(int.Parse(s));
}
}
}
|
갯수와 문자열을 받아 split하여 string 배열을 만들었습니다. foreach문 사용, 하나씩 Parse하여 intList에
추가했습니다.
intList.Sort()함수를 사용해 이를 오름차순 정렬하고 0번째와 마지막 인덱스를 각각 출력했습니다.
백준#2577 - 숫자의 개수 (0) | 2020.04.08 |
---|---|
백준#2562 - 최댓값 (0) | 2020.04.08 |
백준#1110 - 더하기 사이클 (0) | 2020.04.08 |
백준#5585 - 거스름돈 (0) | 2020.04.08 |
백준#10951 - A+B - 4 (0) | 2020.04.08 |