The easiest way would be a recursive solution, which would also help if it does not work with the maximum jump distance.
vector<unsigned> rock{ 2, 5, 1, 1, 7, 4, 9 };
unsigned startpos = 0, jcnt = 0;
bool res = jump(startpos, rock, rock[startpos], jcnt);
cout << "Result: " << ((res) ? "true" : "false") << "Jumps: " << jcnt << "\n";
with:
bool jump(unsigned pos, vector<unsigned> &rock, unsigned jumplen, unsigned &jcnt);