You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
斐波那契数列
|
|
~~~c
|
|
#include<stdio.h>
|
|
int fib(int n){
|
|
if(n<=2){
|
|
return n;
|
|
}else{
|
|
return fib(n-1)+fib(n-2);
|
|
}
|
|
}
|
|
int main(){
|
|
int n;
|
|
printf("请输入想打印的斐波拉契数列:\n");
|
|
scanf("%d",&n);
|
|
printf("斐波那契数列:\n");
|
|
for(int i = 0;i<=n;i++){
|
|
printf("%d ",fib(i));
|
|
}
|
|
return 0;
|
|
}
|
|
~~~
|