{ "question_id": 7446208, "question_title": "求数列第n项值", "question_content": "
求数列第n项值:1,2,3,6,11,20,37,68,125,230,.....例如:第7项为37,第9项为125。
", "difficulty": "简单", "answer_id": 53425424, "answer_content": "\n#include <stdio.h>\n\nint main(void) { \n int n;\n printf("请输入n的值:");\n scanf("%d",&n);\n if(n==1){\n printf("第1项为1\\n");\n }else if(n==2){\n printf("第2项为2\\n");\n }else if(n==3){\n printf("第3项为3\\n");\n }else{\n int f1=1,f2=2,f3=3;\n int i,fn;\n for(i=4;i<=n;i++){\n fn=f1+f2+f3;\n f1=f2;\n f2=f3;\n f3=fn;\n }\n printf("第%d项为%d\\n",n,fn);\n }\n return 0;\n}
\n\n\n", "tag_name": "c++", "cpp": "#include