-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinInStack.cpp
More file actions
51 lines (36 loc) · 978 Bytes
/
Copy pathMinInStack.cpp
File metadata and controls
51 lines (36 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// MinInStack.cpp : Defines the entry point for the console application.
//
// 《剑指Offer——名企面试官精讲典型编程题》代码
// 著作权所有者:何海涛
#include "stdafx.h"
#include "..\MinInStack\StackWithMin.h"
void Test(char* testName, const StackWithMin<int>& stack, int expected)
{
if(testName != NULL)
printf("%s begins: ", testName);
if(stack.min() == expected)
printf("Passed.\n");
else
printf("Failed.\n");
}
int _tmain(int argc, _TCHAR* argv[])
{
StackWithMin<int> stack;
stack.push(3);
Test("Test1", stack, 3);
stack.push(4);
Test("Test2", stack, 3);
stack.push(2);
Test("Test3", stack, 2);
stack.push(3);
Test("Test4", stack, 2);
stack.pop();
Test("Test5", stack, 2);
stack.pop();
Test("Test6", stack, 3);
stack.pop();
Test("Test7", stack, 3);
stack.push(0);
Test("Test8", stack, 0);
return 0;
}