Advertisement
Guest User

Untitled

a guest
Nov 7th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <Windows.h>
  5. #include <list>
  6.  
  7. #define storgeType vector
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     LARGE_INTEGER   freq;
  14.     LARGE_INTEGER   end;
  15.     LARGE_INTEGER   start;
  16.  
  17.     int n;
  18.     cout << "Input number of elements: ";
  19.     cin >> n;
  20.     cout << endl;
  21.  
  22.     ::QueryPerformanceFrequency( &freq );
  23.     ::QueryPerformanceCounter( &start );
  24.  
  25.     storgeType< storgeType< int > > res;
  26.     storgeType< int > v;
  27.  
  28.     for( int i = 0; i < n; i++ )
  29.         v.push_back( i );
  30.  
  31.     do
  32.     {
  33.         res.push_back( v );
  34.     } while ( next_permutation ( v.begin() ,v.end() ) );
  35.  
  36.  
  37.     ::QueryPerformanceCounter( &end );
  38.     long m_llCurrentTimeInMs = (long) ((end.QuadPart - start.QuadPart) * 1000.0 / (double) freq.QuadPart);
  39.     cout << "Finished!" << endl;
  40.     cout << m_llCurrentTimeInMs << endl;
  41.     cin >> n;
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement