#include using namespace std; bool isPalindrome(string &s) { int start=0; int end=s.length()-1; while(start<=end) { if(s[start]!=s[end]) { return false; } start++; end--; } return true; } int main(){ string s; cout<<"ENTER STRING:"; getline(cin,s); int n=s.length(); bool flag=true; for(int i=1;i
#include<bits/stdc++.h>
using namespace std;
bool isPalindrome(string &s)
{
int start=0;
int end=s.length()-1;
while(start<=end)
{
if(s[start]!=s[end])
{
return false;
}
start++;
end--;
}
return true;
}
int main(){
string s;
cout<<"ENTER STRING:";
getline(cin,s);
int n=s.length();
bool flag=true;
for(int i=1;i<n;i++)
{
string lowerHalf=s.substr(0,i);
string upperHalf=s.substr(i,n-i);
if(isPalindrome(lowerHalf) && isPalindrome(upperHalf))
{
flag=false;
cout<<"String A is:"<<lowerHalf<<"\n";
cout<<"String B is:"<<upperHalf<<"\n";
break;
}
}
if(flag)
{
cout<<"NO\n";
}
return 0;
}
change to stdio.h string.h

Step by step
Solved in 3 steps with 3 images









