U E D R , A S I H C RSS

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

No older revisions available

No older revisions available



소스


~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 2021-02-07 05:31:29
Processing time 0.0215 sec