C# 백준 1427번 문제 소트인사이드
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
int[] arr = new int[str.Length];
string result = "";
for(int i = 0; i<str.Length; i++)
{
arr[i] = int.Parse(str.Substring(i, 1)); // 문자열 하나씩 잘라서 배열에 저장
}
Array.Sort(arr); // 오름차순 정렬
Array.Reverse(arr); // 역순으로 - 내림차순 정렬
for (int i = 0; i < str.Length; i++)
{
result += arr[i].ToString();
}
Console.WriteLine(result);
}
}
}