用C语言写一个斐波那契数列
时间: 2023-03-14 13:33:18 浏览: 129
feibonaqi,排班系统c语言设计源码,c语言程序
我可以为您编写一个C语言程序,用于输出斐波那契数列:#include <stdio.h> int main()
{
int n, first = 0, second = 1, next, c;
printf("输入斐波那契数列的元素个数:");
scanf("%d",&n);
printf("斐波那契数列:\n");
for (c = 0; c < n; c++)
{
if (c <= 1)
next = c;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d\n",next);
}
return 0;
}
阅读全文