修正: 斐波那契

This commit is contained in:
flykhan 2023-06-24 10:43:50 +08:00
parent 7b07eb048f
commit f3750b2851
1 changed files with 7 additions and 2 deletions

View File

@ -13,8 +13,13 @@ int main()
int a = 1; int a = 1;
int b = 1; int b = 1;
int c = 0; int c = 0;
cout << a << "\t" << b << "\t";
while (c <= n) if (n >= 1)
cout << a << "\t";
if (n >= 2)
cout << b << "\t";
while (n > 2 && c <= n)
{ {
c = a + b; c = a + b;
if (c <= n) if (c <= n)