#include<iostream>
#include<algorithm>
using namespace std;
int fact(int num) {
if (num <= 1)
return num;
else
return num * fact(num - 1);
}
int main() {
int res;
res = fact(5);
cout << res;
}
'C++' 카테고리의 다른 글
[C++] 재귀호출로 회문 판별하기 (0) | 2020.08.05 |
---|---|
[C++] 재귀호출로 배열의 합 구하기 (0) | 2020.08.05 |
[C++] 삽입정렬 코드 구현 (0) | 2020.08.04 |
[C++] 선택정렬 코드 구현 (0) | 2020.08.04 |
[C++] 이중 연결 리스트 생성, 삽입, 삭제, 출력 코드 구현 (0) | 2020.08.04 |