您的位置:首页 > 其它

我的日记之stl的stack的使用方式

2015-08-17 21:11 399 查看
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<cmath>
#include<stack>
#include<vector>
using namespace std;
stack<char>s;
string ss;
int main()
{
//  int len=strlen(mapp);
int i;
bool flagf=false,flagj=false;
cin>>ss;
for(i=0;i<ss.size();i++)
{
s.push(ss[i]);
if(ss[i]=='-')
flagf=true;
}
char pre;
flagj=true;
if(flagf)
{printf("-");flagj=true;}
while(!s.empty())
{
pre=s.top();
s.pop();
if(pre=='-')
continue;
else if(flagj==true&&pre=='0')
continue;
else if(flagj==true&&pre!='0')
{
printf("%c",pre);
flagj=false;
}
else printf("%c",pre);
}
printf("\n");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: