Answer:
#include <iostream>
using namespace std;
void crack_pin(string a, int low, int res)
{
if (low == res)
cout<<a<<endl;
else
{
for (int i = low; i <= res; i++)
{
swap(a[low], a[i]);
crack_pin(a, low+1, res);
swap(a[low], a[i]);
}
}
}
int main()
{
string str = "ABC";
cout <<"Enter pin guess"<<endl;
getline(cin,str);
int n = str.size();
crack_pin(str, 0, n-1);
return 0;
}
Step-by-step explanation:
Take pin guess from user using getline method in str variable of type string.
Find size of pin guess.
Declare a function crack_pin and send string, starting (0) and ending (n-1) to function.Call the function recursively to find all combinations.If start=end print string else call function again.