wu


私信TA

用户名:cncfvc

访问量:217308

签 名:

读研狗没有时间刷题了~~

等  级
排  名 2
经  验 36238
参赛次数 8
文章发表 265
年  龄 25
在职情况 学生
学  校 电子科技大学
专  业 通信工程

  自我简介:

写代码 真好玩 ~

#include<stdio.h>
int main()
{
	int a[55],i,n;
	a[1]=1;
	a[2]=2;
	a[3]=3;
	for(i=4;i<55;i++)
	{
		a[i]=a[i-1]+a[i-3];
	}
	while(scanf("%d",&n)&&n)
	{
		printf("%d\n",a[n]);
	}
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include<stdio.h>
int main()
{
	int cow1=0,cow2=0,cow3=0,cow4=0,mother=1,cow1_1,cow2_1,cow3_1,cow4_1,mother1;
	int i=1,sum,n;
	scanf("%d",&n);
	for(;i<n;i++)
	{
		cow1_1=mother;
		cow2_1=cow1;
		cow3_1=cow2;
		cow4_1=cow3;
		mother1=mother+cow4_1;
		cow1=cow1_1;
		cow2=cow2_1;
		cow3=cow3_1;
		cow4=cow4_1;
		mother=mother1;
	}
	sum=cow1+cow2+cow3+cow4+mother;
	printf("%d",sum);
}

求大神指点下,怎么优化下!我个菜鸟只能到这步
2018-11-14 21:32:03
费式数列!
2017-12-15 19:23:28
  • «
  • 1
  • »