- 进制转化
将N转化为R进制
#include<iostream>
using namespace std;
//进制转化
//将N转化为R进制
int main() {
char a[100], b[17] = "0123456789ABCDEF";
int n, r,i=0;
cout << "请输入要转化的整数";
cin >> n;
cout << "请输入要转化的进制";
cin >> r;
if (n < 0) {
cout << "-";
n = n * -1;
}
while (n != 0) {
a[i++] = b[n % r];
n = n / r;
}
while (i--) {
cout << a[i];
}
return 0;
}