+ 2
Convert string as palindrome without any predefined methods
If string is jyo8j, need to insert o, y in 5,6 positions. And calculate no of insertions. Which can be done dynamically
2 Réponses
+ 1
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int n=0;
string s;
cout<<"Enter String: ";
cin>>s;
for(int k=s.length()-1,i=0 ; k>=0,i<s.length() ; --k,++i){
if(s[k]==s[i]){
n++;
}
}
if(n==s.length()){
cout<<"Palindrome";
}else{
cout<<"not Palindrome";
}
return 0;
}