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

[ BOJ/C# ] 1427 소트인사이드

by 왹져박사 2023. 11. 4.
728x90

https://www.acmicpc.net/problem/1427

 

1427번: 소트인사이드

첫째 줄에 정렬하려고 하는 수 N이 주어진다. N은 1,000,000,000보다 작거나 같은 자연수이다.

www.acmicpc.net

using System;
using System.IO;

namespace B1427
{
    class Program
    {
        static void Main()
        {
            StreamReader sr = new StreamReader(Console.OpenStandardInput());
            StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());

            string input = sr.ReadLine();
            List<char> list = new List<char>(); ;
            for(int i=0; i < input.Length; i++)
            {
                list.Add(input[i]);
            }
            list = list.OrderByDescending(x=>x).ToList();
            string result = new string(list.ToArray());
            sw.Write(result);
            sr.Close();
            sw.Flush();
            sw.Close();
        }
    }
}

 

728x90