本文共 501 字,大约阅读时间需要 1 分钟。
#include#include #include const int maxn = 1000;char arr[maxn];using namespace std;void sol(int n, int r){ int tot=-1; int temp = n; memset(arr, 0, sizeof(arr)); while(temp!=0){ arr[++tot] = temp%r>9?(temp%r+55):(temp%r+48); temp = temp/r; } for(int i=tot; i>=0; i--){ cout< >n>>r){ if(n>=0) sol(n, r); else{ cout<<"-"; sol(-n, r); } } return 0;}
转载地址:http://yovb.baihongyu.com/