Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef swap_H
- #define swap_h
- #include <vector>
- #include <iostream>
- using namespace std;
- vector<int>swap_elements(vector<int>(n))
- {
- vector<int> newvector(n);
- vector<int> nextvector(n);
- int holder;
- int R = 3;
- int P = 8;
- int B;
- cout << newvector.size() << endl;
- bool isfound = false;
- int count = 0;
- for (int j = 0; j < newvector.size(); j++) {
- if (count == 2){
- isfound = false;
- count = 0;
- }
- if (newvector[j] == 1) {
- count = count + 1;
- if (isfound != true){
- holder = newvector[j];
- if (j + R < newvector.size()){
- newvector[j] = newvector[j + R]; // R will be taken from a vehicle class, R being the speed
- newvector[j + R] = holder;
- isfound = true;
- }
- else{
- newvector[j] = newvector[0]; // R will be taken from a vehicle class, R being the speed
- newvector[0] = holder;
- isfound = true;
- }
- }
- }
- //cout << "Count: " << count << endl;
- cout << newvector[j] << endl;
- //system("pause");
- }
- return newvector;
- }
- #endif
Add Comment
Please, Sign In to add comment