12345678910111213141516171819
#include <iostream> int main() { unsigned int number = 70489026 ; do { const int last_digit = number % 10 ; std::cout << last_digit << ' ' ; if( last_digit == 0 ) std::cout << "zero\n" ; else if( last_digit%2 == 0 ) std::cout << "even\n" ; else std::cout << "odd\n" ; number /= 10 ; } while( number != 0 ) ; }
123456789101112131415
#include <iostream> using namespace std; void classify( int n ) { if ( !n ) return; classify( n / 10 ); int d = n % 10; cout << d << ": " << ( d == 0 ? "Zero" : ( d % 2 ? "Odd" : "Even (and not zero)" ) ) << endl; } int main() { classify( 12345600 ); }