当前位置: 首页>>代码示例>>C++>>正文


C++ MinStack::push方法代码示例

本文整理汇总了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;
}
开发者ID:pkuzw,项目名称:LeetCode-Zhao-Wei-,代码行数:25,代码来源:Min+Stack.cpp

示例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;
}
开发者ID:TomeC,项目名称:leetCode,代码行数:32,代码来源:MinStack.cpp

示例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();
}
开发者ID:guohuiGH,项目名称:codes,代码行数:7,代码来源:155_min_stack.cpp

示例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;
}
开发者ID:anshulmgupta,项目名称:test,代码行数:27,代码来源:Min_Stack.cpp

示例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;
    }
}
开发者ID:nyankosama,项目名称:leetcode,代码行数:9,代码来源:MinStack2.cpp

示例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;
}
开发者ID:husterxsp,项目名称:leetcode,代码行数:10,代码来源:MinStack.cpp

示例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;
}
开发者ID:eagle9,项目名称:palgo,代码行数:10,代码来源:shaun1.cpp

示例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());
}
开发者ID:duxins,项目名称:leetcode,代码行数:11,代码来源:155-min-stack.cpp

示例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;
}
开发者ID:lobalani,项目名称:algo,代码行数:11,代码来源:min-stack.cpp

示例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;
}
开发者ID:lewsn2008,项目名称:leetcode,代码行数:12,代码来源:MinStack.cpp

示例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;
}
开发者ID:CaptainCan,项目名称:Leetcode,代码行数:12,代码来源:155+LL.cpp

示例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;
}
开发者ID:sniperswang,项目名称:dev,代码行数:13,代码来源:test.cpp

示例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");
}
开发者ID:hyfeng,项目名称:leetcode,代码行数:13,代码来源:min_stack.cpp

示例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();

}
开发者ID:xingkungao,项目名称:LeetCode_solutions,代码行数:13,代码来源:min_stack.cpp

示例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;
}
开发者ID:JimberXin,项目名称:Leetcode,代码行数:14,代码来源:Min+Stack.cpp


注:本文中的MinStack::push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。