Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <list>
- using namespace std;
- void echo(list<int> L)
- {
- list<int>::iterator it;
- for(it=L.begin();it!=L.end();it++)
- cout << *it << " ";
- }
- int main()
- {
- list<int>L, L2;
- list<int>::iterator myIt_1, myIt_2, myIt_3;
- int n;
- cin>>n;
- for(int i = 1; i <= n; i++)
- {
- int ch;
- cin>>ch;
- L.push_back(ch);
- }
- int size = L.size(), element = 1, br = 0;
- for(myIt_1=L.begin();myIt_1!=L.end();myIt_1++)
- {
- myIt_2 = myIt_1;
- for(int i = element+1; i<=size; i++)
- {
- myIt_2++;
- if(*myIt_1 == *myIt_2)
- {
- bool isThere = false;
- for(myIt_3=L2.begin();myIt_3!=L2.end();myIt_3++)
- if(*myIt_3 == *myIt_2) isThere = true;
- if(!isThere)
- L2.push_back(*myIt_2);
- br++;
- }
- //cout << *myIt_1 << " <> " << *myIt_2 << " \n\r";
- }
- //cout << "\n";
- element++;
- }
- if(br > 0 && !L2.empty())
- {
- cout << "Povtarqshti se chisla: " << endl;;
- L2.sort();
- echo(L2);
- } else cout << "Nqma povtarqshti se chisla.." << endl;;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement