解题思路:先利用数学知识,求通项
注意事项:
参考代码:
#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 人评分
DNA (C++代码)浏览:667 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)浏览:512 |
陶陶摘苹果 (C语言代码)浏览:1638 |
2^k进制数 (C++代码)使用递归方法浏览:734 |
【亲和数】 (C语言代码)浏览:538 |
众数问题 (C语言代码)浏览:888 |
1009题解浏览:793 |
用筛法求之N内的素数。 (C语言代码)浏览:591 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:707 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:452 |