解题思路:先利用数学知识,求通项
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int str[30]={'\0'};
int i,n;
str[2]=4;
str[3]=10;
while(scanf("%d",&n)==1)
{
if(n<4)
{
printf("%d\n",str[n]);
}
else
{
for(i=4;i<=n;i++)
{
str[i]=str[i-1]+2*(str[i-1]-str[i-2]);
}
printf("%d\n",str[n]);
}
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:625 |
wu-理财计划 (C++代码)浏览:900 |
WU-C语言程序设计教程(第三版)课后习题11.11 (C++代码)(想学链表的可以看看)浏览:1449 |
DNA (C语言描述,蓝桥杯)浏览:1648 |
蚂蚁感冒 (C语言代码)浏览:1405 |
The 3n + 1 problem (C语言代码)浏览:548 |
C二级辅导-统计字符 (C语言描述——用函数求解)浏览:1226 |
C语言程序设计教程(第三版)课后习题8.4 (C++代码)浏览:470 |
C语言训练-自守数问题 (C语言代码)浏览:702 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)简单版浏览:801 |