C++简单代码/4行/斐波那契数列:
class Solution { public: int rectCover(int number) { int res = 1, res_first = 1; for (int i = 2; i <= number; i ++) res += res_first, res_first = res - res_first; return (number == 0) ? 0 : res; } };
C++简单代码/4行/斐波那契数列:
class Solution { public: int rectCover(int number) { int res = 1, res_first = 1; for (int i = 2; i <= number; i ++) res += res_first, res_first = res - res_first; return (number == 0) ? 0 : res; } };