keymasterviriya1150

Untitled

Sep 8th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1.  
  2. #include <iostream>    
  3. #include <algorithm>    
  4.  
  5. int main () {
  6.   int myints[] = {1,2,3};
  7.  
  8.   std::sort (myints,myints+3);
  9.  
  10.   std::cout << "The 3! possible permutations with 3 elements:\n";
  11.   do {
  12.     std::cout << myints[0] << ' ' << myints[1] << ' ' << myints[2] << '\n';
  13.   } while ( std::next_permutation(myints,myints+3) );
  14.  
  15.   std::cout << "After loop: " << myints[0] << ' ' << myints[1] << ' ' << myints[2] << '\n';
  16.  
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment