##为啥0去不掉啊
查看原帖
##为啥0去不掉啊
568865
yan044楼主2022/1/19 10:58
#include<bits/stdc++.h>
using namespace std;

stack<char> p;
string s;

int main()
{
    cin >> s;
    if (s[0] == '-')
	{
		cout << "-";
		for (int i = 1 ; i <= s.length() ; i++)
	    	p.push(s[i]);
	}
    else 
	{
		for (int i = 0 ; i <= s.length() ; i++)
	    	p.push(s[i]);
	}
**	while (p.top() == '0')
	    p.pop();**
	while(!p.empty())
	{
		cout << p.top();
		p.pop();
	}
	return 0;
}
2022/1/19 10:58
加载中...