Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool isSymmetrical( std::queue < int > q )
- {
- int x = q.front(); q.pop();
- std:queue < int > q2;
- int digits = (log( abs( x ) ) / log(10)) + 1;
- int y = x, pw;
- for( int i = 0; i < digits; i++ )
- {
- q2.push( y % 10 );
- y /= 10;
- pw = 1;
- for( int j = 0; j < digits - i - 1; j++ )
- {
- pw *= 10;
- }
- q.push( x / pw );
- x %= pw;
- }
- int d1, d2;
- while( !q.empty() )
- {
- d1 = q.front(); q.pop();
- d2 = q2.front(); q2.pop();
- if( d1 != d2 ) return false;
- }
- return true;
- }
- int main()
- {
- std::queue < int > q;
- while( true )
- {
- int n;
- std::cin >> n;
- if( n <= -1 ) break;
- q.push(n);
- if( isSymmetrical(q) ) std::cout << n << " - True" << endl;
- else std::cout << n << " - False" << endl;
- q.pop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement