Advertisement
STANAANDREY

factorial temp

Aug 27th, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. template<int N>
  6. struct Factorial {
  7.     enum {
  8.         value = Factorial<N-1>::value * N
  9.     };
  10. };
  11.  
  12. template<>
  13. struct Factorial<0> {
  14.     enum { value = 1 };
  15. };//*/
  16.  
  17. int main()
  18. {
  19.     int i = Factorial<4>::value;
  20.     cout << i << endl;
  21.     char c[Factorial<4>::value];
  22.     cout << sizeof(c);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement