标签:blog sp div 问题 log bs amp as tt
回溯问题,可以递归解决,不断试探走一步,走两步
void go(int n,int step,int& sum) { n = n - step; if(n > 0) { go(n,1,sum); go(n,2,sum); } else if(n==0) { sum ++; } } int main(void) { int sum = 0; go(10,1,sum); go(10,2,sum); printf("sum=%d",sum); return 0; }
标签:blog sp div 问题 log bs amp as tt
原文地址:http://www.cnblogs.com/kangbry/p/4058025.html