You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
476 B
22 lines
476 B
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
stack<char> p;
|
|
|
|
int main() {
|
|
char c;
|
|
while (cin >> c) {
|
|
if (c == '-')cout << ("-");//判断正负,如果是负就直接输出,不压栈
|
|
else p.push(c);//否则压进栈里
|
|
}
|
|
//有多少个删除掉多少个
|
|
while (p.top() == '0')//删除前导0
|
|
p.pop();
|
|
//输出
|
|
while (!p.empty())//最后输出反转数
|
|
{
|
|
cout << p.top();
|
|
p.pop();
|
|
}
|
|
return 0;
|
|
} |