Guest User

Untitled

a guest
Apr 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #ifndef swap_H
  2. #define swap_h
  3.  
  4. #include <vector>
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. vector<int>swap_elements(vector<int>(n))
  9. {
  10. vector<int> newvector(n);
  11. vector<int> nextvector(n);
  12. int holder;
  13. int R = 3;
  14. int P = 8;
  15. int B;
  16.  
  17. cout << newvector.size() << endl;
  18. bool isfound = false;
  19. int count = 0;
  20.  
  21. for (int j = 0; j < newvector.size(); j++) {
  22.  
  23. if (count == 2){
  24. isfound = false;
  25. count = 0;
  26. }
  27. if (newvector[j] == 1) {
  28. count = count + 1;
  29. if (isfound != true){
  30.  
  31. holder = newvector[j];
  32. if (j + R < newvector.size()){
  33. newvector[j] = newvector[j + R]; // R will be taken from a vehicle class, R being the speed
  34. newvector[j + R] = holder;
  35. isfound = true;
  36. }
  37. else{
  38. newvector[j] = newvector[0]; // R will be taken from a vehicle class, R being the speed
  39. newvector[0] = holder;
  40. isfound = true;
  41. }
  42. }
  43. }
  44.  
  45. //cout << "Count: " << count << endl;
  46. cout << newvector[j] << endl;
  47. //system("pause");
  48. }
  49.  
  50. return newvector;
  51. }
  52. #endif
Add Comment
Please, Sign In to add comment