Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sort(int x)
- {
- int y, z;
- y = x % 10;
- x /= 10;
- while (x != 0)
- {
- if (x % 10 >= y % 10)
- y = y * 10 + x % 10;
- else
- {
- z = 0;
- while (x % 10 < y % 10 && y > 0)
- {
- z = z * 10 + y % 10;
- y /= 10;
- }
- y = y * 10 + x % 10;
- while (z != 0)
- {
- y = y * 10 + z % 10;
- z /= 10;
- }
- }
- x /= 10;
- }
- return y;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int x;
- cout << "Введите число: ";
- cin >> x;
- x = sort(x);
- cout << endl << "результат: " << x << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement