From 6f3d93664469235e0a6ae7314972ff15dfa0dd01 Mon Sep 17 00:00:00 2001 From: lorem Date: Sun, 16 Sep 2018 13:05:01 +0800 Subject: [PATCH] Delete TestStackDesc.java --- Test/TestStackDesc.java | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 Test/TestStackDesc.java diff --git a/Test/TestStackDesc.java b/Test/TestStackDesc.java deleted file mode 100644 index 159a463..0000000 --- a/Test/TestStackDesc.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.test.desc; -import org.junit.Test; -import java.util.Stack; - -/** - * @author lorem - * @date 2018.9.11 - */ -public class TestStackDesc { - @Test - public void test(){ - Stack stack = new Stack(); - stack.push(1); - stack.push(3); - stack.push(2); - - sortStackByStack(stack); - while(!stack.isEmpty()){ - System.out.println(stack.pop()); - } - } - public void sortStackByStack(Stack stack) { - Stack help = new Stack(); - while(!stack.isEmpty()){ - int cur = stack.pop(); - while(!help.isEmpty() && help.peek()< cur){ - stack.push(help.pop()); - } - help.push(cur); - } - while (!help.isEmpty()){ - stack.push(help.pop()); - } - } -}