文章
8
粉丝
183
获赞
10
访问
32.2k
#include <bits/stdc++.h>
using namespace std;
vector<string> radixArr = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
// 进制转换
string radixConvert(int x,int d){
string str = "";
while(x!=0){
if(x%d >= 16){
return "null";
}
str.insert(0,radixArr[x%d]);
x /= d;
}
return str;
}
int main(){
int n;
while(cin >> n){
cout << radixConvert(n,8) << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发