Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <clocale>
- #include <set>
- #include <algorithm>
- #include <cctype>
- #include <iterator>
- #include <sstream>
- using namespace std;
- int main()
- {
- int n, i, x;
- setlocale(LC_ALL, "rus");
- cout << "Введите размер последовательности: ";
- cin >> n;
- set<int> Posl; // вводимая последовательность
- set<int> Cifry;// ответ
- set<int> trx; //set для цифр трехзначных чисел
- set<int> Proverka; // цифры от 0 до 9
- for (i = 0; i < n; i++) {
- cout << "a[" << i << "] = ";
- cin >> x;
- Posl.insert(x);
- }
- for (i = 0; i < 10; i++) {
- Proverka.insert(i);
- }
- for (set<int>::iterator iter = Posl.begin(); iter != Posl.end(); iter++){// выбираем трехзначные числа и делим их поразрядно
- if (*iter >= 100 && *iter <= 999) {
- x = *iter;
- while (x) {// заносим цифры в set
- trx.insert(x % 10);
- x /= 10;
- }
- }
- }
- set_difference(Proverka.begin(), Proverka.end(), trx.begin(), trx.end(), inserter(Cifry, Cifry.begin()));// ищем не встречающиеся цифры
- for (set<int>::iterator iter = Cifry.begin(); iter != Cifry.end(); iter++)
- cout << *iter << " ";
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement