You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
507 B

#include <bits/stdc++.h>
using namespace std;
int main() {
int p, q, n;
cin >> p >> n >> q;
//现将P进制转换为十进制
int t = 0, f = 1;
while (n != 0) {
t = (n % 10) * f + t;
f = f * p;
n = n / 10;
}
//现在将十进制转换为Q进制
int y[100], num = 0;
do {
y[num++] = t % q;
t = t / q;
} while (t != 0);
//输出结果
for (int i = num - 1; i >= 0; i--) {
cout << y[i];
}
return 0;
}