Created
November 2, 2017 12:11
-
-
Save hansen033/c8e8e1d8b5fd13c1ca331f7d2431737b to your computer and use it in GitHub Desktop.
2017/11/02 上課測驗
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int first, second, max; | |
cout << "請輸入你要小於等於多少數值得費氏數列:\n"; | |
cin >> max; | |
first = 1; | |
second = 1; | |
cout << "1 "; | |
while (true){ | |
if (second<=max){ | |
cout << second << " "; | |
second = second + first; | |
first = second - first; | |
} else { | |
break; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment