'commit'
This commit is contained in:
22
LuoGu/RuMen/P1307.cpp
Normal file
22
LuoGu/RuMen/P1307.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user