From 7e414586bd8279f2dac75f4a2e64e83ef8bc91b8 Mon Sep 17 00:00:00 2001 From: pvzsuxe5b <15779541764@qq.com> Date: Thu, 10 Feb 2022 13:34:49 +0800 Subject: [PATCH] ADD file via upload --- 斐波那契数列..cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 斐波那契数列..cpp diff --git a/斐波那契数列..cpp b/斐波那契数列..cpp new file mode 100644 index 0000000..9a976b2 --- /dev/null +++ b/斐波那契数列..cpp @@ -0,0 +1,24 @@ +#include + +int main() +{ + int t1 = 0, t2 = 1, nextTerm = 0, n; + + printf("����һ������: "); + scanf("%d", &n); + + + printf("쳲���������: %d, %d, ", t1, t2); + + nextTerm = t1 + t2; + + while(nextTerm <= n) + { + printf("%d, ",nextTerm); + t1 = t2; + t2 = nextTerm; + nextTerm = t1 + t2; + } + + return 0; +}