Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean P(Deque from, Deque to, Stack s) {
- if (from.size() != 0) {
- s.push(from.getFirst());
- from.removeFirst();
- return true;
- } else
- return false;
- }
- public static boolean V(Deque from, Deque to, Stack s) {
- if (s.size() != 0) {
- to.addFirst(s.pop());
- return true;
- } else
- return false;
- }
- //请实现go函数
- public static void go(Deque from, Deque to, Stack s) {
- if(to.size()==9)
- answers++;
- Deque f = from.clone();
- Deque t = to.clone();
- Stack stack = s.clone();
- //if(stack.size()<4) {
- if (P(from, to, s))// P V选择错误 则不继续迭代
- go(from, to, s);
- //}
- if (V(f, t, stack))
- go(f, t, stack);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement