Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. typedef int elementtypel;
  2. #include <iostream>
  3. #include <time.h>
  4. #include "lista.h"
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9. int N;
  10. cout<<"Unesi broj brojeva za generiranje: ";
  11. cin>>N;
  12. lst L;
  13. InitL(L);
  14. srand(time(NULL));
  15. cout<<"Generirani brojevi: \n";
  16. for(int i=0; i<N; i++){
  17. elementl e = EndL(L);
  18. int pseudo = rand()%20;
  19. InsertL(L, e, pseudo);
  20. cout<<pseudo<<" ";
  21. }
  22. cout<<"\n\nIspis cijele liste: \n";
  23. elementl e = FirstL(L);
  24. while(e != EndL(L)){
  25. cout<<RetrieveL(L,e)<<" ";
  26. e = NextL(L,e);
  27. }
  28. elementl ex = FirstL(L);
  29. while(ex != EndL(L)){
  30. elementl exi = NextL(L,ex);
  31. while(exi != EndL(L)){
  32. if(RetrieveL(L,ex) == RetrieveL(L,exi)){
  33. DeleteL(L,exi);
  34. break;
  35. }
  36. exi = NextL(L,exi);
  37. }
  38. ex = NextL(L,ex);
  39. }
  40. cout<<"\n\nIspis cijele liste bez duplikata: \n";
  41. elementl ef = FirstL(L);
  42. while(ef != EndL(L)){
  43. cout<<RetrieveL(L,ef)<<" ";
  44. ef = NextL(L,ef);
  45. }
  46. DisposeL(L);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement