Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- ////////////////////////////////
- int main()
- {
- int n[] = {1, 1, 2, 2, 3, 4, 5};
- int k = 1;
- int nSize = sizeof(n)/4;
- cout <<"size of array = " << nSize << endl;
- int *p = new int[nSize];
- p[0] = n[0];
- for(int i = 1; i < nSize; i++)
- {
- if(n[i-1] != n[i])
- {
- //
- k++;
- p[k] = n[i];
- }
- }
- cout << "k = " << k <<endl;
- // cout << n[0] << endl;
- for(int i = 0; i < k+1 ; i++)
- {
- cout << p[i] <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement