#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
int fibonacci[20], first, second;
first=second =fibonacci[1] = fibonacci[0] = 1;//前两项
for (int i = 2; i < 20; i++) {
fibonacci[i] = first + second;
first = second;
second = fibonacci[i];
}
puts("斐波那契前20项为:");
for (int i = 0; i < 20; i++) {
printf("%d ", fibonacci[i]);
}
return 0;
}
登录后提交答案