解题思路:双递归,构建一个类似二叉树的结构,左子树+1,右子树+2
注意事项:
参考代码:
#include <iostream>
#include <deque>
#include <string>
#include <iterator>
#include <vector>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string.h>
using namespace std;
int ans;
int n;
void dfs(int a)
{
if(a>n)
return ;
if(a==n)
{
ans++;
return ;
}
dfs(a+1);
dfs(a+2);
}
int main()
{
cin>>n;
dfs(0);
cout<<ans<<endl;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:646 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:495 |
ASCII帮了大忙浏览:749 |
数组输出 (C语言代码)错误???浏览:565 |
【金明的预算方案】 (C++代码)浏览:843 |
蚂蚁感冒 (C语言代码)浏览:1334 |
简单的a+b (C语言代码)浏览:419 |
矩形面积交 (C++代码)浏览:1130 |
简单的a+b (C语言代码)浏览:950 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:575 |