[백준] 1427번 소트인사이드 / C++

#문제

백준 1427번 소트인사이드

#풀이

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL);

	int N;
	cin >> N;
	string S = to_string(N);

	sort(S.rbegin(), S.rend());

	for (int i = 0; i < S.size(); ++i)
	{
		cout << S[i];
	}

	return 0;
}

#정리

입력 받은 숫자를 string으로 변환 후, 역으로 정렬하여 출력.




    Enjoy Reading This Article?

    Here are some more articles you might like to read next:

  • [백준] 11656번 접미사 배열 / C++
  • [백준] 1181번 단어 정렬 / C++
  • [백준] 11650번 좌표 정렬하기 / C++
  • [백준] 1934번 최소공배수 / C++
  • [백준] 1037번 최소공배수 / C++