Bob103

set1

Jul 8th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <set>
  6. #include <iterator>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. ifstream in("input.txt");
  12. ofstream out("output.txt");
  13.  
  14.  
  15. int main()
  16.  
  17. {
  18. int c = 0;
  19. int i;
  20. vector < int > v;
  21. set < int > set;
  22. while (in >> i)
  23.  
  24. {
  25. v.push_back(i);
  26. }
  27.  
  28. int a = 0, b = 0;
  29.  
  30. copy(v.begin(), v.end(), ostream_iterator <int>(out, " "));
  31.  
  32. out << endl;
  33.  
  34. for (int i = 0; i < v.size(); i++)
  35. {
  36. int m = set.size();
  37. int k = abs(v[i]);
  38.  
  39. while (k>0)
  40. {
  41. a = k % 10;
  42. k = k / 10;
  43. set.insert(a);
  44.  
  45. if (set.size() > m)
  46. {
  47.  
  48. out << a << " ";
  49. out << endl;
  50. m = set.size();
  51. c++;
  52.  
  53. }
  54. }
  55. }
  56. return 0;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment