Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <iomanip>
  4. #include <string>
  5. #include <algorithm>
  6. #include <cmath>
  7. #include <stdexcept>
  8. #include <type_traits>
  9. #include <cctype>
  10. #include <list>
  11. #include <deque>
  12. #include <stack>
  13. #include <functional>
  14. using namespace std;
  15.  
  16. //primjer 3, zadatak 4
  17. // provjeriti sto neki divlji rez daje
  18. int Fun(list<double> v){
  19. auto p=v.begin();
  20. auto q=v.begin();
  21. p++;
  22. while (p!=v.end()){
  23. while (p!=v.end() && *p!=*q) {
  24. cout<<*p<<" ";
  25. p++;
  26. }
  27. auto temp=p;
  28. if (p==v.end()) return 0;
  29. while (p!=v.end() && *p==*q){
  30. p++;
  31. q++;
  32. }
  33. if (p==v.end()) return distance(p, q);
  34. p=temp;
  35. }
  36. return 0;
  37. }
  38.  
  39.  
  40. int main()
  41. {
  42. list<double>v={1, 2, 3, 1, 2, 3, 1, 2, 3};
  43. cout<<Fun(v);
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement