Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. void removeDuplicates(int[], int);
  8.  
  9. int main() {
  10.  
  11. int n;
  12.  
  13. cin >> n;
  14.  
  15. string s = to_string(n);
  16.  
  17. if (s.length() < 20 || s.length() > 50) {
  18. return 0;
  19. }
  20.  
  21. char array [s.size() + 1];
  22.  
  23. strcpy(array, s.c_str());
  24.  
  25. int arr[s.size() + 1];
  26. for (int i = 0; i < s.size() +1 ; ++i) {
  27. arr[i] = array[i];
  28. }
  29. removeDuplicates(arr,s.length());
  30. }
  31.  
  32. void removeDuplicates(int arr[], int n) {
  33. int i;
  34.  
  35. set<int> s;
  36. for (i = 0; i < n; i++) {
  37.  
  38. // insert into set
  39. s.insert(arr[i]);
  40. }
  41.  
  42. set<int>::iterator it;
  43.  
  44. // Print the array with duplicates removed
  45. cout << "\nAfter removing duplicates:\n";
  46. for (it = s.begin(); it != s.end(); ++it)
  47. cout << *it << ", ";
  48. cout << '\n';
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement