Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- AES
- sprintf
- SHA512
- program
- traits
- Scala
- CustomTab
- Functional
- c++
- web
- ChromeTab
- template
- sha256
- SHA1
- async
- haskell
- type_traits
- Reflect
- WebView
- coroutines
- go
- kotlin
- Android
- design pattern
- Chrono
- stringprintf
- Observer
- ranges
- Clojure
- RAII
Archives
- Today
- Total
프로그래밍 검색 블로그
템플릿 메타 프로그래밍 피보나치 본문
1 2 3 4 5 6 7 8 9 10 11 12 | template<unsigned long long N> struct fibonacci{ static const unsigned long long value = fibonacci<N-1>::value + fibonacci<N-2>::value; }; template<> struct fibonacci<1LL>{ static const unsigned long long value = 1LL; }; template<> struct fibonacci<0LL>{ static const unsigned long long value = 0LL; }; | cs |
테스트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> using namespace std; int main(){ cout << fibonacci<1>::value << endl; cout << fibonacci<2>::value << endl; cout << fibonacci<3>::value << endl; cout << fibonacci<4>::value << endl; cout << fibonacci<5>::value << endl; cout << fibonacci<6>::value << endl; cout << fibonacci<7>::value << endl; cout << fibonacci<8>::value << endl; cout << fibonacci<9>::value << endl; cout << fibonacci<10>::value << endl; } | cs |
'연습장' 카테고리의 다른 글
함수형 피타고라스 삼각형 구하기 (0) | 2017.10.14 |
---|---|
템플릿 메타 프로그래밍 소수 구하기 (0) | 2017.10.06 |
템플릿 메타 프로그래밍 최대공약수 최대공배수 (0) | 2017.10.05 |
템플릿 메타 프로그래밍 binary (0) | 2017.10.05 |
템플릿 메타 프로그래밍 팩토리얼 (0) | 2017.10.05 |
Comments