#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;
}
#include<iostream>
using namespace std;
int main()
{
string s1, s2;
cout << "Enter string: ";
cin >> s1;
for (int i = s1.length()-1; i >= 0; i--)
{
s2 += s1[i];
}
if (s1 == s2)
{
cout << "Palindrome!" << endl;
}
else
{
cout << "Not Palindrome!" << endl;
}
return 0;
}
Code Example |
---|
Cpp :: c++ remove element from vector |
Cpp :: case label in c++ |
Cpp :: C++ break with for loop |
Cpp :: for loop f# |
Cpp :: how to append to a vector c++ |
Cpp :: How to write into files in C++ |
Cpp :: comparator in sort c++ |
Cpp :: C++ Vector Operation Add Element |
Cpp :: memmove |
Cpp :: selection sort c++ algorithm |
Cpp :: cpp print variable value |
Cpp :: string vector to string c++ |
Cpp :: fizzbuzz c++ |
Cpp :: string length in c++ |
Cpp :: c detect os |
Cpp :: c++ builder |
Cpp :: sort vector from largest to smallest |
Cpp :: C++ New Lines |
Cpp :: show stack c++ |
Cpp :: c++ program to generate all the prime numbers between 1 and n |
Cpp :: find a number in vector c++ |
Cpp :: set size in c++ |
Cpp :: inheritance in c++ |
Cpp :: tuple vector c++ |
Cpp :: how to grab numbers from string in cpp |
Cpp :: c++ fonksion pointer |
Cpp :: print Colored text in C++ |
Cpp :: min heap stl |
Cpp :: find vector size in c++ |
Cpp :: read a whole line from the input |