I. Palindrome
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
--------------------------------------------------------------------------------------------------------------------------------
Given a number is a palindrome number print "YES" otherwise, print "NOis a palindrome number print "YES" otherwise, print "NOis a palindrome number print "YES" otherwise, print "NO
-----------------------------------------------------------------------------------------------------------------------------
. Print 2 lines that contain the following respectively:
- Print in a reversed order and not leading zeroes.
- If N is a palindrome number print "YES" otherwise, print "NO.
Note:
A palindrome number is a number that reads the same forward or backward.
For example: 12321, 101 are palindrome numbers, while 1201, 221 are not.
A leading zero is any 0 digit that comes before the first nonzero digit in a number for example : numbers (005 , 01 , 0123 , 02 , 000250 ) are leading zeroes but ( 5 , 123 , 20 ,2500 ) not leading zeroes numbers .
Input
Only one line containing a number
.
Output
Print the answer required above.
Examples:
-----------------------------------------------------------------------------------------------------------------------------
program:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int num,m,rev=0,digit;
cin>>num;
m=num;
while(num!=0)
{
digit=num%10;
rev=digit+(rev*10);
num/=10;
}
if(m==rev)
{
cout<<rev<<endl;
cout<<"YES"<<endl;
}else
{
cout<<rev<<endl;
cout<<"NO"<<endl;
}
return 0;
}
-----------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment