1、数组打印斐波那契数列c++
时间: 2023-11-14 17:07:17 浏览: 98
C++打印斐波那契数列
5星 · 资源好评率100%
Sure, I can help you with that! Here's some code to print the Fibonacci sequence in an array using C:
```
#include <stdio.h>
int main() {
int n, i;
printf("Enter the number of terms in the Fibonacci sequence: ");
scanf("%d", &n);
int fib[n];
fib[0] = 0;
fib[1] = 1;
for(i = 2; i < n; i++) {
fib[i] = fib[i-1] + fib[i-2];
}
printf("The Fibonacci sequence is: ");
for(i = 0; i < n; i++) {
printf("%d ", fib[i]);
}
printf("\n");
return 0;
}
```
I hope that helps!
阅读全文