Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- class Node
- {
- int val;
- Node next;
- Node(int v, Node n)
- {
- val = v;
- next = n;
- }
- }
- class LinkedList
- {
- Node first;
- Node last;
- int count = 0;
- public void add(Node in)
- {
- if (count == 0)
- {
- first = in;
- last = in;
- count++;
- return;
- }
- last.next = in;
- last = in;
- count++;
- }
- public void sout()
- {
- Node buff = first;
- while (buff != null)
- {
- System.out.print(buff.val + " ");
- buff = buff.next;
- }
- System.out.println("");
- }
- }
- class Run
- {
- public static void main(String[] args)
- {
- LinkedList test = new LinkedList();
- test.add(new Node(1, null));
- test.add(new Node(2, null));
- test.add(new Node(3, null));
- test.add(new Node(4, null));
- test.add(new Node(5, null));
- test.add(new Node(6, null));
- test.add(new Node(5, null));
- test.add(new Node(6, null));
- test.sout();
- Homework5.rl(test,6);
- test.sout();
- Homework5.rev(test);
- test.sout();
- }
- }*/
Add Comment
Please, Sign In to add comment