求解!用vfp写程序!!!已知一个数列第一项,第二项分别是0,1,第三项开始每一项是前两项之和,
答案:2 悬赏:10 手机版
解决时间 2021-02-04 19:33
- 提问者网友:难遇难求
- 2021-02-04 01:56
求解!用vfp写程序!!!已知一个数列第一项,第二项分别是0,1,第三项开始每一项是前两项之和,
最佳答案
- 五星知识达人网友:不想翻身的咸鱼
- 2021-02-04 03:16
SET TALK OFF
DIMENSION a(100)
a(1)=0
a(2)=1
FOR i=3 TO 100
a(i)=a(i-1)+a(i-2)
NEXT i
FOR i=100 TO 1 STEP -1
? a(i)
NEXT i
RETURN
DIMENSION a(100)
a(1)=0
a(2)=1
FOR i=3 TO 100
a(i)=a(i-1)+a(i-2)
NEXT i
FOR i=100 TO 1 STEP -1
? a(i)
NEXT i
RETURN
全部回答
- 1楼网友:轻雾山林
- 2021-02-04 04:11
已经尽力了,只能输出92个左右,太大了。
#include
int main()
{
int i = 2;
unsigned long a = 0;
unsigned long b = 1;
unsigned long data[100];
data[0] = a;
data[1] = b;
while(i < 99)
{
unsigned long c = b;
b = a + c;
a = c;
data[i] = a + b;
i++;
}
for(;i>-1; i--)
{
printf("%d:", i);
printf("%ld\n", data[i]);
}
return 0;
}
#include
int main()
{
int i = 2;
unsigned long a = 0;
unsigned long b = 1;
unsigned long data[100];
data[0] = a;
data[1] = b;
while(i < 99)
{
unsigned long c = b;
b = a + c;
a = c;
data[i] = a + b;
i++;
}
for(;i>-1; i--)
{
printf("%d:", i);
printf("%ld\n", data[i]);
}
return 0;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯