void test() { const int length = 5; int stack_push[length] = { 1,2,3,4,5}; int stack_Pop1[length] = {5,4,3,2,1}; int stack_Pop2[length] = { 3,1,2,4,5}; bool possible = IsPopOrder(stack_push, stack_Pop1, length); possible = IsPopOrder(stack_push, stack_Pop2, length); int stack_push3[1] = { 1}; int stack_Pop3[1] = {1}; possible = IsPopOrder(stack_push3, stack_Pop3, 1); }
// ====================测试代码==================== void Test(char* testName, const int* pPush, const int* pPop, int nLength, bool expected) { if(testName != NULL) printf("%s begins: ", testName); if(IsPopOrder(pPush, pPop, nLength) == expected) printf("Passed.\n"); else printf("failed.\n"); }
void Test() { int a[5] = {1,2,3,4,5}; int b[5] = {4,5,3,2,1}; bool num = 0; num = IsPopOrder(a,b,5); if (num == true) { cout << "ºÏ·¨" << endl; } else { cout << "·Ç·¨" << endl; } }