#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<stack>
using namespace std;
char Ch[17]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int main()
{
stack<int>s;
int n=0,a=0;
cin>>a;
if(a==0)//系统漏洞,a==0的情况
{
cout<<"0"<<endl;
return 0;
}
while(a!=0)
{
s.push(a%16);
a=a/16;
}
while(!s.empty())
{
if(s.top()>=10)
{
cout<<Ch[s.top()];
}
else
cout<<s.top();
s.pop();
}
return 0;
}
蓝桥杯+进制转换+STL stack的使用
最新推荐文章于 2023-10-28 14:12:49 发布