From 11e4842c1af53e4588b451cd61478e4058fe8d16 Mon Sep 17 00:00:00 2001 From: pfrwco89l <2788679620@qq.com> Date: Sat, 19 Feb 2022 19:45:12 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E6=96=90=E6=B3=A2=E9=82=A3=E5=A5=91?= =?UTF-8?q?=E6=95=B0=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 斐波那契数列 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 斐波那契数列 diff --git a/斐波那契数列 b/斐波那契数列 new file mode 100644 index 0000000..3c7ee06 --- /dev/null +++ b/斐波那契数列 @@ -0,0 +1,27 @@ +#include + +void fibonac(int n, int a[]) +{ + int j; + for( j = 2; j < n; j ++) + { + a[j] = a[j - 1] + a[j - 2]; + } +} + +int main() +{ + int n, a[1000010] = {1,1}; + int i, k = 0; + scanf("%d", &n); + fibonac(n, a); + for( i = 0; i < n; i ++) + { + printf("%12d ", a[i]); + k ++; + if(k % 5 == 0) + printf("\n"); + + return 0; + } +} \ No newline at end of file