SHARE
TWEET

palndrome

a guest Jun 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void stringArray(char *); //method declaration
  6.  
  7. void strFunc(string );
  8.  
  9. int main()
  10. {
  11.     //char arr1[6] = {'H','E','L','L','O','\0'};
  12.  
  13.      string str="Hello World as";
  14.      //int wordCount=0;
  15.     // bool flag = false;
  16.  
  17.      /*for (int i=0; i<str.size(); i++) {
  18.         if(str[i]!=' ') {
  19.             if (flag=false){
  20.                 wordCount++;
  21.                 flag = true;
  22.             }
  23.             else {
  24.                     flag=false;
  25.             }
  26.             }
  27.      }
  28.      cout<<"Word Count: "<<wordCount<<endl;
  29. */
  30.      strFunc(str);
  31.      cout<<str<<endl;
  32.      string strReverse = "";
  33.  
  34.      for(int i=str.size()-1; i>=0; i--) {
  35.         //strReverse=strReverse+str[i];
  36.         strReverse += str[i];
  37.      }
  38.      cout<<strReverse<<endl;
  39.  
  40.      string b = "MOS";
  41.      string c = "";
  42.  
  43.      for(int i=b.size()-1;i>=0; i--) {
  44.         c+=b[i];
  45.      }
  46.  
  47.      if (b==c) {
  48.         cout<<"Palindrome found"<<endl;
  49.      }
  50.      else{
  51.         cout<<"Palindrome not found"<<endl;
  52.      }
  53.  
  54.      return 0;
  55.  
  56. }
  57.  
  58. void strFunc(string a) {
  59.     //cout<<a<<endl;
  60.     //a[0] = 'E';
  61.     //cout<<a<<endl;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top