二进制和八进制:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x;
while(n--)
{
cin>>x;
string res="";
while(x)
{
res=to_string(x%8) + res;
x=x/8;
}
cout<<res<<endl;
}
return 0;
}
十六进制:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x;
while(n--)
{
cin>>x;
string res="";
while(x)
{
int t=x%16;
if(t<10) res=to_string(t) + res;
else
{
res="ABCDEF"[t-10] + res;
}
x=x/16;
}
cout<<res<<endl;
}
return 0;
}