반응형
SMALL
using System;
using System.Collections.Generic;
using System.Linq;
namespace Study11
{
class App
{
//생성자
public App()
{
string[] arr = {
"but", "i", "wont", "hesitate", "no", "more", "no", "it", "cannot", "wait", "im", "your"
};
//여기부터 작성하세요
IEnumerable<string> sequence = from ar in arr
orderby ar ascending //사전순 오름차순으로 정렬
orderby ar.Length ascending //글자 수 대로 오름차순으로 정렬
select ar;
IEnumerable<string> sequence2 = sequence.Distinct(); //중복제거
foreach (string ar in sequence2) //컬렉션 요소 출력
{
Console.WriteLine(ar);
}
//출력
//i
//im
//it
//no
//but
//more
//wait
//wont
//yours
//cannot
//hesitate
}
}
}
결과창

반응형
LIST
'Algorithm > BOJ' 카테고리의 다른 글
| [BOJ] 10988 팰린드롬 C# 사용 (1) | 2023.01.17 |
|---|---|
| [알고스팟] 록 페스티벌 C# 문제 풀이 (0) | 2023.01.17 |
| [BOJ] 10173 니모를 찾아서 C# 이용 (0) | 2023.01.12 |
| [BOJ] 4458 첫 글자를 대문자로 C# 이용 (1) | 2023.01.12 |
| [BOJ] 2711 오타맨 고창영 (0) | 2023.01.12 |