Question: #include #include #include using namespace std; void palindrome(string st) //function to check string at index i is palindrome or not { int l = 0;
#include
using namespace std;
void palindrome(string st) //function to check string at index i is palindrome or not { int l = 0; int h = st.size()-1; while( h > l) { if( st [l++] != st[h--]) //if string is not palindrome then return to main function return; } cout << "\t"; cout << st <<" "; //if string is palindrome then print that string cout << " "; }
int main()
{ vector < string > str; // Declaring Vector of String type string input; int count = 0; cout << "(~) Input the strings (Enter'Q' or 'q' to end the input list): " << endl; cout << " "; while(input.compare("q") !=0 && input.compare("Q") != 0) //loop until user quits { cout << "\t"; str.push_back(input); //add valid string to vector cin >> input; //input next string } for(int i = 0 ; i for(int j=0 ; j This is a code to take strings as inputs and print the palindrome elements in it. I want to fix the bug that when i enter two palindromes nearby it doesnot identify it as an duplicate and prints it twice. I need to fix this . as an examle if i enter peep peep neeb noob as inputs it will give peep peep as the output. Instead of that i need to print peep once only ##Please note that I need you to edit this code. I know that we can use map as well but try to do it without it if possible if not its is ok
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
