#include<iostream>
#include<stack>
using namespace std;
void solve(int n)
{
if(n<=9&&n>=-9)
cout<<n<<endl;
bool open=false;
if(n<0){
n=-n;
open=true;
}
stack<char> st;
while(n){
int tmp=n%16;
if(tmp>=10)
st.push('A'+tmp-10);
else
st.push(tmp+'0');
n/=16;
}
if(open)
cout<<"-"<<ends;
while(!st.empty()){
cout<<st.top()<<ends;
st.pop();
}
cout<<endl;
}
int main(int argc,char *argv[])
{
if(argc!=2)
return 1;
solve(atoi(argv[1]));
return 0;
}
10进制转换成16进制
最新推荐文章于 2023-08-28 20:08:24 发布