Skip to content

Commit 4f31f66

Browse files
committed
Pallindrome String Checker
1 parent a41a159 commit 4f31f66

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Check_String_Palindrome/Source1.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include<iostream>
2+
#include<string>
3+
4+
bool checkStringPallindrome(string inputString);
5+
6+
bool checkStringPallindrome(string inputString) {
7+
//if (inputString.length() % 2 == 1) {
8+
for (int i = 0; i < inputString.length()/2; i++) {
9+
if (inputString.at[i] != inputString.at[inputString.length() - 1 - i]) {
10+
return false;
11+
}
12+
}
13+
//}
14+
//else {
15+
16+
//}
17+
return true;
18+
}
19+
int main(){
20+
21+
string input = "";
22+
std::getline(std::cin, input);
23+
std::cout<<checkStringPallindrome(input);
24+
25+
system("pause");
26+
return 1;
27+
}

Check_String_Palindrome/problem.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
You are given a string consisting of letters from a-z and A-Z. No any special characters. A palindrome is a word which is equal to itself when reversed. Examples are DAD, MOM, APCPA. Words like TIGER, RAT are not palindromes.
2+
Input and Output:
3+
The function should take a queue of characters as input and return True or False as output. If the queue is empty return true.
4+
5+
6+
Sample Input 1:
7+
ABCBA
8+
Sample Output 1:
9+
true
10+
Sample Input 2:
11+
PrOGraMiNG
12+
Sample Output 2:
13+
false
14+
Sample Input 3:
15+
AA
16+
Sample Output 3:
17+
true

0 commit comments

Comments
 (0)