11 2014 档案
摘要:#includeusing namespace std;/*递归法*//*递归法会在函数中调用自己,注意结束条件,避免无限循环,递归法的原理是压栈出栈*//*例1:f(n)=n! 则f(n)=f(n-1)*n*/int f1(int n){ if (n > n; cout > n; ...
阅读全文
摘要:/*递推法*//*斐波那契数列 1 1 2 3 5 8 13..... f(n)?*//*递推法的特点是由前向后推算,因此注意起始条件,并在推算过程中保存结果供下一步推算使用~*/#includeusing namespace std;int f1(int n){ if (n > n; ...
阅读全文
摘要:/*穷举法*//*鸡兔同笼35头,94足,鸡兔各几只?*/#includeconst int Num = 35;const int Foots = 94;int main(){ int cN;//鸡 int rN;//兔 for (cN = 0; cN <= 35; cN++) ...
阅读全文

浙公网安备 33010602011771号