Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int n = 0;
- scanf("%d", &n);
- getchar();
- int nums[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- for (int i = 0; i < n; i++)
- {
- char x = getchar();
- nums[x - 48]++;
- }
- int i = n - 1;
- for (int it = 9; it >= 0; it--)
- {
- if (nums[it] > 0)
- {
- if (i - nums[it] < 0)
- {
- while (i--)
- putchar(it + 48);
- break;
- }
- i -= nums[it];
- while (nums[it]--)
- putchar(it + 48);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement