bool CanJump(int A[], int n)
{
int k = A[0];
int i = 1;
while(i <= k && i < n)
{
if (k < (A[i]+i)) k =(A[i]+i);
++i;
}
return i>=n;
}
#include <stdio.h>
int main(int argc, char** argv)
{
int a[] = {2,3,1,1,4};
int n = sizeof(a)/sizeof(int);
printf("%d\n", CanJump(a,n));
int b[] = {3,2,1,0,4};
n = sizeof(b)/sizeof(int);
printf("%d\n", CanJump(b,n));
return 0;
}