Facebook
From Queen Horse, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 66
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     vector <string> words;
  10.     string cont,word;
  11.     string check1="Q";
  12.     string check2="q";
  13.     int x, length;
  14.     int count;
  15.     int flag;
  16.  
  17.    
  18.     do{
  19.         printf("Please Enter The Word :-");
  20.         cin >> word;
  21.         words.push_back(word);
  22.         count++;
  23.         printf("Enter 'Q' or 'q' to stop entering words :- ");
  24.         cin>> cont;
  25.        
  26.     }while(cont.compare(check1) != 0 && cont.compare(check2) != 0 );
  27.     cout << "Total Of Numbers Of Words Inputed is :-" << count<< endl;
  28.     cout << "Palindrome Word List :-" << endl;
  29.     for (auto i = words.begin(); i != words.end(); ++i) {
  30.       flag=0;
  31.       string temp;
  32.       temp=*i;
  33.       length=temp.length();
  34.       for(int y=0;y < temp.length() ;y++){
  35.         if(temp[y] != temp[length-y-1]){
  36.             flag = 1;
  37.             break;
  38.       }  
  39.     }
  40.     if (flag == 0) {
  41.         cout << temp << endl;
  42.     }    
  43.  
  44.    
  45.   }
  46.     return 0;
  47. }
  48.  
  49.