505 views

1 Answer

0 votes
0 votes
we can solve it using backtracking

string s;

int permutation(int i , int n){

if(i==n-1)

cout<<s;

else{

for(int j=i;j<n;j++){

swap(s[j], s[i]);

permutation(i+1 , n);

swap(s[j] ,s[i]);

}

}

}

Related questions

0 votes
0 votes
2 answers
1
go_editor asked Sep 20, 2018
406 views
Write a complete ANSI C code using recursion to calculate the $sum(s)$ of the digits of an integer number (i) consisting of maximum 5 digits. For example, (1) = if $i=123...