示例#1
0
void Test3()
{
	StackWithMin<int> min;
	min.Push(1);
	min.Push(2);
	min.Push(1);
	cout << min.Min() << endl;
	min.Pop();
	cout << min.Min() << endl;
}
// test
int main() {
	StackWithMin s;
	s.Push(4);
	cout << s.GetMin() << "\t Expected 4" << endl;
	s.Push(3);
	cout << s.GetMin() << "\t Expected 3" << endl;
	
	s.Pop();
	cout << s.GetMin() << "\t Expected 4" << endl;
	s.Push(5);
	cout << s.GetMin() << "\t Expected 4" << endl;
	s.Push(1);
	cout << s.GetMin() << "\t Expected 1" << endl;
	
	s.Pop();
	cout << s.GetMin() << "\t Expected 4" << endl;
	
	s.Pop();
	cout << s.GetMin() << "\t Expected 4" << endl;
	return 0;
}
示例#3
0
void Test2()
{
	StackWithMin<int> min;
	min.Push(1);
	min.Pop();
	min.Push(1);
	min.Min();
	cout << min.Top() << endl;
	if (!min.Empty())
	{
		cout << "pass" << endl;
	}
	else
	{
		cout << "false" << endl;
	}

}