标签:return src i++ get nps size class div odps
bool recursion(int* target, int srcSize, int* src, int num, int pst){ int cnt=0,i; int oodpst=0,evenpst=srcSize/2; int arr[5001]={0}; if (srcSize<=num) { for (i=0; i<srcSize; i++) { if (target[pst++] != src[i]) return false; } return true; } for (i=0; i<srcSize; i++) { if (i%2) arr[oodpst++]=src[i]; else arr[evenpst++]=src[i]; } for (i=0; i<num; i++) { if (target[pst++] != arr[i]) return false; } return recursion(target,srcSize-num,arr+num,num,pst); } bool isMagic(int* target, int targetSize){ int src[5001]={0},i,pst=0; for (i=1; i<=targetSize; i++) src[i-1]=i; for (i=1; i<=targetSize; i++) { if (recursion(target,targetSize,src,i,0)) return true; } return false; }
标签:return src i++ get nps size class div odps
原文地址:https://www.cnblogs.com/ganxiang/p/13938605.html