没法判断吧,除了一个一个慢慢pop出来。。。
by 小闸蟹 @ 2018-03-29 23:09:53
map <int ,int >a
记录的时候,把map里面的数加,
被说你不会map
by Kiel @ 2018-03-29 23:13:11
stack有iterator吗
by moongazer @ 2018-03-29 23:16:12
```cpp
...
#include<stack>
stack<int> s1,s2;
...
bool work(){
bool flag=false;
...
while(!s1.empty()){
if(s1.top()<0)flag=true;
s2.push(s1.top());
s1.pop();
}
while(!s2.empty())s1.push(s2.top());
...
return flag;
}
int main(){
...
bool flag=work();
...
reutrn 0;
}
```
by 斯德哥尔摩 @ 2018-03-29 23:16:25
还有s2.pop();呢~@[斯德哥尔摩](/space/show?uid=49998)
by 小闸蟹 @ 2018-03-29 23:18:25
@[小闸蟹](/space/show?uid=59062) 没有也无所谓,只不过数据大会RE。。。
by 斯德哥尔摩 @ 2018-03-29 23:19:27
但。。。但是。。。您的第二个while退不出去啊。。。@[斯德哥尔摩](/space/show?uid=49998)
by 小闸蟹 @ 2018-03-29 23:23:10
@[小闸蟹](/space/show?uid=59062) 额。。。好像有道理。。。算我错。。。
by 斯德哥尔摩 @ 2018-03-29 23:25:43
@[斯德哥尔摩](/space/show?uid=49998) 难道不是开个bool instack[MAXN]就好了嘛,push的时候变true,pop的时候变false,数字大就hash搞一下,这样效率会高很多的吧!
by ViXbob @ 2018-03-29 23:29:15
@[ViXbob](/space/show?uid=50971) 重复数据怎么办?
by 斯德哥尔摩 @ 2018-03-29 23:32:39