Inflearn Community Q&A
안녕하세요, 강의 너무 쉽고 이해 잘되네요!!
Written on
·
158
1
마지막에 피보나치 예제를 주셨는데 제가 코딩하니까 검은빈화면만 뜨고 아무것도 안되어 막혔습니다..
int pibonaci(int n)
{
static int temp1 ;
static int temp2 ;
static int temp3 ;
temp3 = temp1 + temp2; //피보나치 수열 값들 저장할변수
while (n == 1) // 재귀함수로 반복되기전에 첫번째만 대입..
{
temp1 = 0; temp2 = 0; temp3 = 1;
}
cout << t3 << "\t";
t1 = t2;
t2 = t3;
cout << "pibonaci's [" << n << "] th count complete." << endl;
if (n == 20) // 20번째까지만 재귀함수 출력
goto sodone;
pibonaci(n + 1);
sodone:
return 100;
}
int main()
{
pibonaci(1);
//n 은 피보나치 수열의 n 번째 라는 표시입니다.
// 0 0 1 1 2 3 5 8 13 ....
}
문제가 무엇일까요? 아시는 수강생께도 여쭤봅니다 ㅠㅠ
C++





