Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- using namespace std;
- int remove(int *arr, int n) {
- int pos = 0;
- for (int i = 0 ; i != n ; ++i) {
- if (arr[i] == arr[pos])
- continue;
- arr[++pos] = arr[i];
- }
- return pos + 1;
- }
- int main() {
- int n;
- cin >> n;
- int *arr = new int[n];
- for (int i = 0 ; i != n ; ++i) {
- cin >> arr[i];
- }
- sort(arr, arr + n);
- int remain = remove(arr, n);
- // Output
- cout << remain << endl;
- for (int i = 0 ; i != remain ; i++)
- cout << arr[i] << " ";
- cout.flush();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement