fork download
  1. #include<bits/stdc++.h>
  2. using namespace std ;
  3.  
  4. int main()
  5. {
  6. string s = "0123" ;
  7. int i = 0 ;
  8. do
  9. {
  10.  
  11. cout<<i++<<" "<<s<<endl ;
  12. }while(next_permutation(s.begin(),s.end())) ;
  13.  
  14. }
Success #stdin #stdout 0s 4552KB
stdin
Standard input is empty
stdout
0 0123
1 0132
2 0213
3 0231
4 0312
5 0321
6 1023
7 1032
8 1203
9 1230
10 1302
11 1320
12 2013
13 2031
14 2103
15 2130
16 2301
17 2310
18 3012
19 3021
20 3102
21 3120
22 3201
23 3210