#include<iostream>
#include<ctype.h>
using namespace std;
int main() {
string s; cin >> s;
int a = 0;
for(int i = 0; i < (s.length() / 2); i++)
if(s[i] == s[s.length() - 1 - i]) a++;
if(a == (s.length() / 2)) cout << "YES";
else cout << "NO";
return 0;
}
// Check whether the string is a palindrome or not.
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
int l = 0;
int h = s.length()-1;
while(h > l){
if(s[l++] != s[h--]){
cout << "Not a palindrome" << endl;
return 0;
}
}
cout << "Is a palindrome" << endl;
return 0;
}
#include <iostream>
bool isPalindrome (int number) {
int decomposed = number, reversed = 0;
while (decomposed) {
reversed = 10 * reversed + (decomposed % 10);
decomposed /= 10;
}
return reversed == number;
}
class Solution{
public:
int isPalindrome(string S)
{
// Your code goes here
int n=S.length();
for(int i=0;i<n/2;i++)
{
if(S[i]!=S[n-1-i])
{
return 0;
}
}
return 1;
}
};
Code Example |
---|
Cpp :: length of string in c++ |
Cpp :: what is - in c++ |
Cpp :: how to know datatype of something in c++ |
Cpp :: c++ get the line which call a function |
Cpp :: cpp mark getter as const |
Cpp :: fizzbuzz c++ |
Cpp :: substr in cpp |
Cpp :: c++ print out workds |
Cpp :: c++ do every 1 minutes |
Cpp :: priority queue in c++ |
Cpp :: copying a set to vector in c++ |
Cpp :: how to get hcf of two number in c++ |
Cpp :: c plus plus |
Cpp :: c function as paramter |
Cpp :: C++ continue with for loop |
Cpp :: inline c++ |
Cpp :: size of a matrix using vector c++ |
Cpp :: c++ tuple |
Cpp :: how to format decimal palces in c++ |
Cpp :: grep xargs sed |
Cpp :: string comparison c++ |
Cpp :: how to grab numbers from string in cpp |
Cpp :: how to check char array equality in C++ |
Cpp :: google test assert stdout |
Cpp :: c++ get active thread count |
Cpp :: set iterator |
Cpp :: Euler constant |
Cpp :: how to declare an enum variable c++ |
Cpp :: c++ classes |
Cpp :: C++ Vector Operation Access Elements |