Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <chrono>
- using namespace std;
- template<int N>
- class Factorial {
- public:
- enum { value = N * Factorial<N - 1>::value };
- };
- template<>
- class Factorial<1> {
- public:
- enum { value = 1 };
- };
- int main()
- {
- std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
- std::cout << Factorial<10>::value;
- std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
- std::cout << "Time difference = " << std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count() << "[µs]" << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement