解题思路:列出前几项,发现字符串满足s[i]=s[i-2]+s[i-1],所以很容易用递归写出结果。
#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int N = 2000; string a[20]; void print_(int x){ if(x>1){ print_(x-2); print_(x-1); } else cout<<a[x]; } int main() { int n; a[0]="0";a[1]="1"; scanf("%d",&n); print_(n); }
0.0分
1 人评分
WU-C语言程序设计教程(第三版)课后习题11.11 (C++代码)(想学链表的可以看看)浏览:1358 |
Tom数 (C语言代码)浏览:527 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:518 |
C二级辅导-公约公倍 (C语言代码)浏览:483 |
分糖果 (C语言代码)浏览:920 |
复数求和 (C语言代码)浏览:929 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:492 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:555 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:568 |
上车人数 (C语言代码)浏览:713 |