"It seems strange to meet computer geeks who're still primarily running Windows... as if they were still cooking on a wood stove or something." - mbp
FrontPage › MoniWikiACL › C › 피보나치수열
#include <iostream> #include <fstream> using namespace std; int arrFibonacci[100000] = { 0, }; int fibonacci ( int number ) { int ret = 0; if ( number <= 0 ) { ret = -1; } else if ( number == 1 || number == 2 ) { ret = 1; } else { if ( arrFibonacci[number] == 0 ) { arrFibonacci[number] = fibonacci(number-1) + fibonacci(number-2); } ret = arrFibonacci[number]; } return ret; } int main() { for ( int i = 1; i <= 10; i++ ) { cout << fibonacci(i) << endl; } return 0; }