본문 바로가기
알고리즘/백준 BOJ

[BOJ C#] 1181 단어 정렬

by 왹져박사 2023. 1. 12.
728x90

case #1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1181
{
    class App
    {
        //생성자
        public App()
        {
            string[] arr = {
                "but", "i", "wont", "hesitate", "no", "more", "no", "it", "cannot", "wait", "im", "your"
            };

            //여기부터 작성하세요 
            for(int i = 1; i < arr.Length; i++)
            {
                var strs = from str in arr
                           where str.Length==i
                           orderby str ascending
                           select str;
                foreach (string str in strs)
                {
                    Console.WriteLine(str);
                }

            }

            //출력 
            //i
            //im
            //it
            //no
            //but
            //more
            //wait
            //wont
            //yours
            //cannot
            //hesitate

        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1181
{
    class Program
    {
        static void Main(string[] args)
        {
            new App();
        }
    }
}

 

아직 쿼리문이 익숙하지 않아 다시 공부하며 작성하였다!

728x90

'알고리즘 > 백준 BOJ' 카테고리의 다른 글

[BOJ C#] 11720 숫자의 합  (0) 2023.01.15
[BOJ C#] 10988 팰린드롬  (0) 2023.01.15
[BOJ C#] 2711 오타맨 고창영  (0) 2023.01.12
[BOJ C#] 10173 니모를 찾아서  (0) 2023.01.12
[BOJ C#] 4458 첫 글자를 대문자로  (0) 2023.01.12