您的位置:首页 > 其它

计蒜客 第18题:跳跃游戏

2015-03-23 16:10 155 查看
#include <iostream>
using namespace std ;

bool  jump( int A[] , int len , int step)
{
if ( step == len-1) return true ;
for ( int i = A[step];i > 0 ;i--)
{
if (jump(A,len,step+i)) return true  ;
else
A[step+i] = -1 ;
}
return false ;
}

int main()
{
int A[10000];
int n ;
cin >> n ;
for ( int i = 0 ; i < n ;++i)
cin >>A[i] ;
if(jump(A,n,0)) cout << "true" << endl ;
else cout << "false" << endl ;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: