int main(int argc, char* argv []) {
	StackWithMin stack;
	auto list = { 3, 5, 1, 5, 2, 4 };
	for (int n : list) stack.push(n);
	while (!stack.empty()) {
		cout << "v: " << stack.top() << " min: " << stack.min() << endl;
		stack.pop();
	}
	return 0;
}
예제 #2
0
int main(int argc, char const *argv[])
{
	StackWithMin<int> ss;
	ss.push(4);
	ss.push(9);
	ss.push(1);
	ss.push(11);
	ss.push(6);
	cout << "min:" << ss.min() << endl;
	cout << "top:" << ss.top() << endl;
	ss.pop(); 
	cout << "min:" << ss.min() << endl;
	cout << "top:" << ss.top() << endl;
	if (ss.empty() == true)
	{
		cout << "the stack is empty!" <<endl;
	}
	else
	{
		cout << "the stack is not empty!" <<endl;
		cout << "the stack's size is:" << ss.size() <<endl;
	}
	return 0;
}