U E D R , A S I H C RSS

피보나치/이동현,오승혁

소스


~cpp 
#include <iostream>
using namespace std;

int fibo(int);

int main(){
	while(true)
	{
		
	int input;
	cout << "숫자를 입력하시오 : ";
	
	do{	
		cin >> input;
		if(input <= 0)
			return 0;
	}while(input <= 0);

	cout << input <<"번째 숫자는 "<< fibo(input) << " 입니다.\n";

	}
	return 0;
}

int fibo(int in){
	if(in == 1 || in == 2)
		return 1;
	else
		return fibo(in-1) + fibo(in-2);		
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0121 sec