蓝桥杯+进制转换+STL stack的使用

来源:互联网 发布:如何卸载mac的app 编辑:程序博客网 时间:2024/05/16 05:52
#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;}

0 0
原创粉丝点击