Ass 9
Ass 9
#include <stack>
#include <string>
#include <algorithm> // for transform, remove_if
using namespace std;
// Function to preprocess the string: remove spaces, punctuation, and make lowercase
string preprocessString(const string &str)
{
string cleanedString;
for (char ch :str)//for (char ch : str) is a range-based for loop in C++ that iterates over each
character in the string str. It is part of C++11 and later versions.
{
if (isalnum(ch))
{
cleanedString += tolower(ch); // only add alphanumeric characters
}
}
return cleanedString;
}
return reversedStr;
}
int main() {
string input;
cout << "Enter a string: ";
getline(cin, input);
return 0;
}