Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <clocale>
  4. #include <set>
  5. #include <algorithm>
  6. #include <cctype>
  7. #include <iterator>
  8. #include <sstream>
  9. using namespace std;
  10. int main()
  11. {
  12. int n, i, x;
  13. setlocale(LC_ALL, "rus");
  14. cout << "Введите размер последовательности: ";
  15. cin >> n;
  16. set<int> Posl; // вводимая последовательность
  17. set<int> Cifry;// ответ
  18. set<int> trx; //set для цифр трехзначных чисел
  19. set<int> Proverka; // цифры от 0 до 9
  20. for (i = 0; i < n; i++) {
  21. cout << "a[" << i << "] = ";
  22. cin >> x;
  23. Posl.insert(x);
  24. }
  25. for (i = 0; i < 10; i++) {
  26. Proverka.insert(i);
  27. }
  28.  
  29. for (set<int>::iterator iter = Posl.begin(); iter != Posl.end(); iter++){// выбираем трехзначные числа и делим их поразрядно
  30. if (*iter >= 100 && *iter <= 999) {
  31. x = *iter;
  32. while (x) {// заносим цифры в set
  33. trx.insert(x % 10);
  34. x /= 10;
  35. }
  36. }
  37. }
  38. set_difference(Proverka.begin(), Proverka.end(), trx.begin(), trx.end(), inserter(Cifry, Cifry.begin()));// ищем не встречающиеся цифры
  39. for (set<int>::iterator iter = Cifry.begin(); iter != Cifry.end(); iter++)
  40. cout << *iter << " ";
  41. cout << endl;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement