Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <ctime>
- #include <iterator>
- #include <algorithm>
- int main()
- {
- using namespace std;
- srand(time(NULL));
- int N = rand() * rand() % 100000; // Произвольно заданное число
- cout << "N = " << N << endl;
- // Подготавливаем контейнер типа множество
- set<int, less<int>> numbers;
- // Заполняем контейнер цифрами из числа N
- while (N >= 1)
- {
- numbers.insert( N % 10 );
- N /= 10;
- }
- // Выводим цифры на экран
- ostream_iterator<int> ositer(cout, " ");
- cout << "There are digits: ";
- copy(numbers.begin(), numbers.end(), ositer);
- system("pause>nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement