本文整理汇总了C++中MinStack::push方法的典型用法代码示例。如果您正苦于以下问题:C++ MinStack::push方法的具体用法?C++ MinStack::push怎么用?C++ MinStack::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MinStack
的用法示例。
在下文中一共展示了MinStack::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
/*push(2147483646),push(2147483646),push(2147483647),top,pop,getMin,pop,getMin,pop,push(2147483647),
top,getMin,push(-2147483648),top,getMin,pop,getMin*/
MinStack ms;
ms.push(2147483646);
ms.push(2147483646);
ms.push(2147483647);
ms.top();
ms.pop();
ms.getMin();
ms.pop();
ms.getMin();
ms.pop();
ms.push(2147483647);
ms.top();
ms.getMin();
ms.push(-2147483648);
ms.top();
ms.getMin();
ms.pop();
ms.getMin();
return 0;
}
示例2: main
int main ()
{
MinStack m;
m.push (2);
m.push (2);
m.push (3);
m.push (5);
cout<<m.getMin ()<<endl;
cout<<m.top ()<<endl;
m.pop ();
cout<<m.getMin ()<<endl;
cout<<m.top ()<<endl;
m.push (1);
//m.pop ();
cout<<m.getMin ()<<endl;
cout<<m.top ()<<endl;
m.pop ();
cout<<m.getMin ()<<endl;
cout<<m.top ()<<endl;
m.pop ();
cout<<m.getMin ()<<endl;
cout<<m.top ()<<endl;
m.pop ();
cout<<m.getMin ()<<endl;
cout<<m.top ()<<endl;
return 0;
}
示例3: main
int main () {
MinStack st;
st.push(2);st.push(0);st.push(3);
st.push(1);
cout << st.top() << endl;
cout << st.getMin();
}
示例4: test_case_one
void test_case_one(){
MinStack ms;
ms.push(10);
ms.push(20);
ms.push(5);
ms.push(15);
ms.push(3);
ms.push(6);
ms.push(2);
ms.push(1);
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
cout << ms.get_min() << endl;
cout << "Element : " << ms.pop() << endl;
}
示例5: main
int main(){
MinStack s;
s.push(3);
s.push(2);
s.push(1);
for (int i = 0; i < 3; i++){
cout << "min:" << s.getMin() << endl;
}
}
示例6: main
int main () {
MinStack* obj = new MinStack();
obj->push(0);
obj->push(1);
obj->push(0);
obj->getMin();
obj->pop();
obj->getMin();
return 0;
}
示例7: main
int main() {
MinStack minStack;
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
cout << minStack.getMin() << "--> Returns -3" << endl;
minStack.pop();
cout << minStack.top() << "--> Returns 0" << endl;
cout << minStack.getMin() << "--> Returns -2" << endl;
}
示例8: MinStack
TEST(leetcode_155_min_stack, Basic)
{
MinStack *minStack = new MinStack();
minStack->push(-2);
minStack->push(0);
minStack->push(-3);
EXPECT_EQ(-3, minStack->getMin());
minStack->pop();
EXPECT_EQ(0, minStack->top());
EXPECT_EQ(-2, minStack->getMin());
}
示例9: main
int main(){
MinStack stack;
stack.push(-2);
stack.push(0);
stack.push(-1);
std::cout << stack.getMin() << std::endl;
std::cout << stack.top() << std::endl;
stack.pop();
std::cout << stack.getMin() << std::endl;
return 0;
}
示例10: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
MinStack stk;
stk.push(0);
stk.push(1);
stk.push(0);
int v1 = stk.getMin();
stk.pop();
int v2 = stk.getMin();
cout << "v1 : " << v1 << ", v2 : " << v2 << endl;
return 0;
}
示例11: main
int main(void)
{
MinStack engine;
engine.push(-2);
engine.push(0);
engine.push(-1);
cout << engine.getMin() << '\n';
cout << engine.top() << '\n';
engine.pop();
cout << engine.getMin() << '\n';
return 0;
}
示例12: main
int main()
{
MinStack minStack;
minStack.push(-2);
minStack.push(0);
minStack.push(-3);
cout << minStack.getMin() << endl; // --> Returns -3.
minStack.pop();
cout << minStack.top() << endl; // --> Returns 0.
cout << minStack.getMin() << endl; // --> Returns -2.
return 0;
}
示例13: main
int main(){
MinStack st;
st.push(2);
st.push(3);
st.pop();
st.push(1);
st.push(6);
st.pop();
st.push(7);
cout<<st.getMin()<<endl;
system("pause");
}
示例14: main
int main() {
MinStack m;
m.push(3);
m.push(2);
m.push(1);
cout << m.getMin() << endl;
m.pop();
cout << m.getMin() << endl;
m.pop();
cout << m.getMin() << endl;
m.pop();
}
示例15: main
int main(){
MinStack stk;
stk.push(3);
stk.push(1);
stk.push(8);
int minS = stk.getMin();
stk.push(7);
stk.pop();
stk.pop();
stk.push(12);
minS = stk.getMin();
getchar();
return 0;
}