+ 1
i am trying to find out weather the entered string is palindrome or not ,but this code isn't giving the correct output.
#include <iostream> using namespace std; string isPalindrome(string s, int n) { int i=0; for(;i<n;i++) { if(s[i]==s[n-i-1]) continue; else return "No"; } return "Yes"; } int main() { //code int n; // size of the string cin >>n; string s; // cin >> s; cout << isPalindrome(s,n) << endl; return 0; }
2 Answers
+ 1
Inputs:
5
12721
Works fine
Edit:
else{
return "No";
break;
}
0
Try to enter a non palindrome string