3
Recur
- #include <iostream>
- using namespace std;
- void printd( int );
- void printi( int i )
- {
- if ( i < 0 )
- {
- cout.put( '-' );
- i = -i;
- }
- printd( i );
- }
- void printd( int i )
- {
- int d = i/10;
- if ( d )
- printd( d );
- cout.put( char(i%10 + '0') );
- }
- int main()
- {
- int x;
- x = 12345;
- cout << x << "=";
- printi( x );
- cout << endl;
- x = -x;
- cout << x << "=";
- printi( x );
- cout << endl;
- x = 0;
- cout << x << "=";
- printi( x );
- cout << endl;
- }
Commentaires