Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- string sortida(int p, vector<int>& v) {
- int tam = v.size();
- vector<bool> aux(tam, false);
- while(not aux[p]) {
- aux[p] = true;
- if (v[p] > 0) {
- if (p + v[p] >= tam) return "dreta";
- p += v[p];
- }
- else if (v[p] < 0) {
- if (p + v[p] < 0) return "esquerra";
- p += v[p];
- }
- }
- return "mai";
- }
- //JosepRivaille
Advertisement
Add Comment
Please, Sign In to add comment