#include<bits/stdc++.h> using namespace std ; int main() { string s = "0123" ; int i = 0 ; do { cout<<i++<<" "<<s<<endl ; }while(next_permutation(s.begin(),s.end())) ; }
Standard input is empty
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