The objective of my problem is to extract all of the vowels, digits, and symbols from a string and put each char/int in their respective stacks (a vowel stack, a digit stack, and a symbol stack). After iterating through the string and extracting what's needed, I have to do arithmetic with the first two digits in the stack (the last two in the string) depending on what the last symbol in the string was.
One of the constraints is that I cannot have duplicates in the stack; the way that I dealt with this constraint is by having a vector that contained vowels, digits, and symbols that have already been used and each time I go through the logic of checking if the current character of the string is a vowel, digit, or symbol, I check to see if the character is already 'used' (aka present in the used vector). However, I was just informed that we aren't allowed to use vectors in this assignment so I am genuinely at a loss. I thought about creating a 'find' method to search through the stack, but that would require popping the whole stack and I don't think that's an option for me as I have to display and do things w the items in the digit and symbol stacks. Also, in the rubric it is specified that I can only use push(), pop(), isEmpty(), peek(), isFull().
Here is the code responsible for checking and adding to the stack:
// traverse through the string
for (int i = 0; i < toParse.length(); i++)
{
// if the char is a vowel, add it to the vowel stack (if it's not already in the stack)
if(isVowel(toParse[i]) == true)
{
if(find(used.begin(), used.end(), tolower(toParse[i])) == used.end())
{
vowels.push(tolower(toParse[i]));
used.push_back(tolower(toParse[i]));
}
}
// if the char is a digit, add it to the digit stack (if it's not already there)
if(isdigit(toParse[i]))
{
if(find(used.begin(), used.end(), toParse[i]) == used.end() )
{
digits.push(atoi(&toParse[i]));
used.push_back(toParse[i]);
}
}
// if the char is a symbol, add it to the symbol stack regardless of whether it's already there or not
if(isSymbol(toParse[i]))
{
if(find(used.begin(), used.end(), toParse[i]) == used.end() )
{
symbols.push(toParse[i]);
used.push_back(toParse[i]);
}
}
}
Thank you for reading; also I'm not expecting anyone to do my homework I would just like a little guidance in the right direction!
Edit 1: As requested, here is the exact text of my task: [1]: https://i.stack.imgur.com/crM1P.png