Skip to content

Commit 9583c51

Browse files
authored
Merge pull request deutranium#162 from AtigPurohit/master
Issue deutranium#161
2 parents f0f5dce + 7f67dc5 commit 9583c51

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Palindrome/StringPalindrome.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//to check if a string is palindrome or not
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
string s;
9+
getline(cin, s);
10+
char ch;
11+
string str;
12+
for (int i = 0; i < s.length(); i++)
13+
{
14+
ch = s.at(i);
15+
if(ch != ' ')
16+
str = ch+str;
17+
}
18+
if(str == s)
19+
cout<<"Palindrome"<<endl;
20+
else
21+
cout<<"Not Palindrome"<<endl;
22+
return 0;
23+
}

Palindrome/palindrome.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.*;
2+
class palindrome
3+
{
4+
public static void main()
5+
{
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Enter your word");
8+
String str = sc.nextLine();
9+
String s = str;
10+
String st = "";
11+
char ch;int i;
12+
for(i=0;i<str.length();i++)
13+
{
14+
ch = str.charAt(i);
15+
st = ch+st;
16+
}
17+
if(s.equalsIgnoreCase(st))
18+
System.out.println("Palindrome word");
19+
else
20+
System.out.println("Not a Palindrome word");
21+
}
22+
}
23+

0 commit comments

Comments
 (0)