把代码中的m换成2就行了(其他进制同理)
2025-08-01 17:13:14
发布于:四川
0阅读
0回复
0点赞
//十进制转n进制
#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[] = "0123456789ABCDEF";
void f(int x){
if(x==0){
return;
}
f(x/m);
int b=x%m;
cout<<a[b];
}
int main(){
cin>>n>>m;
f(n);
return 0;
}
这里空空如也
有帮助,赞一个