I have written the below code but cannot get my head around how the input string can be compared with the ALPHABET array, and how the inverse can be returned. Any help would be appreciated
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>
#include<limits>
using namespace std;
bool permutationCheck(const string &input)
{
const string ALPHABET("ABCDEFGHIJKLMNOPQRSTUVWXYZ.,' "); //Declaring ALPHABET string to compare against input
if (ALPHABET.length() == input.length()) //comparing the lengths of the ALPHABET string and input to see if it matches
{
if (is_permutation(ALPHABET.begin(), ALPHABET.end(), input.begin())) //Checks if input is permutation of ALPHABET
{
return (true);
}
else
{
return (false);
}
}
else
{
return (false); //Returned if lengths do not match
}
}
string input; //storing the input
cout << "Enter a permutation of the alphabet" << endl;
getline(cin, input);
cout << permutationCheck(input) << endl; //returning the function
system("pause");
cin.ignore(256, '\n');
string inverseinput;
cout << "Enter a Permutation of the alphabet" << endl;
getline(cin, inverseinput);
cout << inversePermutation(inverseinput,input) << endl;
system("pause");
return 0;
}