Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef int elementtypel;
- #include <iostream>
- #include <time.h>
- #include "lista.h"
- using namespace std;
- int main(){
- int N;
- cout<<"Unesi broj brojeva za generiranje: ";
- cin>>N;
- lst L;
- InitL(L);
- srand(time(NULL));
- cout<<"Generirani brojevi: \n";
- for(int i=0; i<N; i++){
- elementl e = EndL(L);
- int pseudo = rand()%20;
- InsertL(L, e, pseudo);
- cout<<pseudo<<" ";
- }
- cout<<"\n\nIspis cijele liste: \n";
- elementl e = FirstL(L);
- while(e != EndL(L)){
- cout<<RetrieveL(L,e)<<" ";
- e = NextL(L,e);
- }
- elementl ex = FirstL(L);
- while(ex != EndL(L)){
- elementl exi = NextL(L,ex);
- while(exi != EndL(L)){
- if(RetrieveL(L,ex) == RetrieveL(L,exi)){
- DeleteL(L,exi);
- break;
- }
- exi = NextL(L,exi);
- }
- ex = NextL(L,ex);
- }
- cout<<"\n\nIspis cijele liste bez duplikata: \n";
- elementl ef = FirstL(L);
- while(ef != EndL(L)){
- cout<<RetrieveL(L,ef)<<" ";
- ef = NextL(L,ef);
- }
- DisposeL(L);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement