There was an error while loading. Please reload this page.
1 parent 6c5b990 commit d95c68aCopy full SHA for d95c68a
problems/isIntegerPalindromeWithoutString.cpp
@@ -0,0 +1,37 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+
4
+bool solve(long int n)
5
+{
6
+ long int orig_n = n;
7
+ stack<long int>st;
8
+ while(n > 0)
9
+ {
10
+ long int tmp = n%10;
11
+ st.push(tmp);
12
+ n = n/10;
13
+ }
14
+ n = orig_n;
15
16
17
18
+ if(tmp != st.top())
19
+ return false;
20
21
+ st.pop();
22
23
24
+ return true;
25
+}
26
27
+int main()
28
29
+ long int n;
30
+ cin>>n;
31
32
+ if(solve(n))
33
+ cout<<"PALINDROME"<<endl;
34
+ else
35
+ cout<<"NOT A PALINDROME"<<endl;
36
+ return 0;
37
0 commit comments