Little Jay

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

알고리즘/BOJ

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

Jay, Lee 2021. 5. 4. 16:41
#include <iostream>
#include <algorithm>
using namespace std;

int main() {

	int arr[10];
	int n;
	int cnt = 0;
	cin >> n;

	while (n != 0) {
		arr[cnt] = n % 10;
		n /= 10;
		cnt++;
	}

	sort(arr, arr + cnt, greater<int>());

	for (int i = 0; i < cnt; i++) {
		cout << arr[i];
	}

	return 0;
}
Comments