本文整理汇总了C++中MinStack::getMin方法的典型用法代码示例。如果您正苦于以下问题:C++ MinStack::getMin方法的具体用法?C++ MinStack::getMin怎么用?C++ MinStack::getMin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MinStack
的用法示例。
在下文中一共展示了MinStack::getMin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
MinStack stack;
stack.push(10);
stack.push(6);
stack.push(10);
stack.push(20);
stack.push(8);
stack.push(10);
stack.push(10);
stack.push(-110);
stack.push(10);
cout << stack.top() << endl;
cout << stack.getMin() << endl;
stack.pop();
stack.pop();
stack.pop();
stack.pop();
stack.pop();
stack.pop();
stack.pop();
stack.pop();
stack.pop();
stack.pop();
cout << stack.top() << endl;
cout << stack.getMin() << endl;
return 0;
}
示例2: 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;
}
示例3: 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;
}
示例4: main
int main () {
MinStack* obj = new MinStack();
obj->push(0);
obj->push(1);
obj->push(0);
obj->getMin();
obj->pop();
obj->getMin();
return 0;
}
示例5: 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());
}
示例6: 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;
}
示例7: _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;
}
示例8: 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;
}
示例9: 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;
}
示例10:
TEST_F(SolutionTest, case1) {
MinStack mstack;
for (int i = 100; i >= 0; i--) {
mstack.push(i);
EXPECT_EQ(mstack.getMin(), i);
EXPECT_EQ(mstack.top(), i);
}
EXPECT_EQ(mstack.getMin(), 0);
EXPECT_EQ(mstack.top(), 0);
mstack.pop();
EXPECT_EQ(mstack.getMin(), 1);
EXPECT_EQ(mstack.top(), 1);
}
示例11: 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();
}
示例12: 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;
}
示例13: main
int main () {
MinStack st;
st.push(2);st.push(0);st.push(3);
st.push(1);
cout << st.top() << endl;
cout << st.getMin();
}
示例14: main
int main()
{
MinStack ms;
ms.push(2);
ms.push(0);
ms.push(3);
ms.push(0);
cout << ms.getMin() << endl;
ms.pop();
cout << ms.getMin() << endl;
ms.pop();
cout << ms.getMin() << endl;
ms.pop();
cout << ms.getMin() << endl;
return 0;
}
示例15: main
int main()
{
int result;
MinStack s;
s.push(-10000);
s.push(-9999);
s.push(-9998);
s.push(-9997);
s.push(-9996);
s.push(-9995);
s.push(-9994);
s.push(-9993);
s.push(-9992);
s.push(-9991);
s.push(-9990);
s.show();
result = s.getMin();
cout << "the getMin result = " << result << endl;
result = s.top();
cout << "the top result = " << result << endl;
s.pop();
s.show();
return 0;
}