简单算法--输出一个整形数任意进制的表示

// qmakeCpp
#include 
#include 

using namespace std ;

int main( void ) {
    int mark = 0 ;
    int n=0 , base = 0 , x=0 , a[100] ;
    while( mark != -1 ){
        cout << "Please input the number you need to transfer:" ;
        cin >> n  ;
        cout << "Please input the base:" ;
        cin >> base ;
        while( n ) {
            a[ x++ ] = n % base ;
            n /= base ;
        }
        --x ;
        while( x >= 0 ){
            cout << a[ x-- ] << " " ;
        }
        x = 0 ;  // !
        cout << endl ;
        cout << "To exit please input -1 , input others otherwise . :" ;
        cin >> mark ;
    }
    cout << "Please pay attention to the blank space in result. " ;
    cout << "You may need to deal the result deeply , for example change 10 to a/A etc. when the base is 16." << endl ;
    return EXIT_SUCCESS ;
}


简单算法--输出一个整形数任意进制的表示_第1张图片

你可能感兴趣的:(输出一个整形数任意进制的表示)