Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool IsPalindrome (int n)
- {
- int n1=n,NewN=0;
- int k=0;
- while (n1>0)
- {
- k=n1%10;
- NewN+=k;
- n1/=10;
- NewN*=10;
- }
- NewN/=10;
- return (NewN==n)? true:false;
- }
- int main()
- {
- int n;
- cin>>n;
- int sum=0;
- for (int i=1;i<=n;i++)
- if (IsPalindrome(i)) sum++;
- cout<<sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement