diff --git "a/1,\350\256\276\347\275\256\350\264\246\345\217\267.bat" "b/1,\350\256\276\347\275\256\350\264\246\345\217\267.bat" new file mode 100644 index 0000000000000000000000000000000000000000..80ffb4dc1853fd7400f396aea304c3adeb2ffe9a --- /dev/null +++ "b/1,\350\256\276\347\275\256\350\264\246\345\217\267.bat" @@ -0,0 +1,2 @@ +git config --global user.name "曾钰华" +git config --global user.email "1210673897@qq.com" \ No newline at end of file diff --git "a/2,\345\210\207\346\215\242\345\210\206\346\224\257.bat" "b/2,\345\210\207\346\215\242\345\210\206\346\224\257.bat" new file mode 100644 index 0000000000000000000000000000000000000000..f55c005783d3b5931b17831b84a60f4b28cd415c --- /dev/null +++ "b/2,\345\210\207\346\215\242\345\210\206\346\224\257.bat" @@ -0,0 +1,2 @@ +git branck 2 +git checkout 2 \ No newline at end of file diff --git "a/3,\350\207\252\345\212\250\346\217\220\344\272\244.bat" "b/3,\350\207\252\345\212\250\346\217\220\344\272\244.bat" new file mode 100644 index 0000000000000000000000000000000000000000..0fbd52fa8111ae13721da1f2c119822552292813 --- /dev/null +++ "b/3,\350\207\252\345\212\250\346\217\220\344\272\244.bat" @@ -0,0 +1,3 @@ +git add . +git commit -m "AutoPush" +git push \ No newline at end of file diff --git a/l1.java b/l1.java new file mode 100644 index 0000000000000000000000000000000000000000..3491bc47b78b7a9126f516899a4e6717d1af5560 --- /dev/null +++ b/l1.java @@ -0,0 +1,189 @@ +public class LinkedList { + + Node first; + Node last; + int size = 0; + + + public LinkedList() { + + } + + public LinkedList(String s) { + Node newNode = new Node(null, null, s); + first = newNode; + last = newNode; + size++; + } + + + public void add(String s) { + Node newNode = new Node(null, null, s); + if (size == 0) { + first = newNode; + last = newNode; + } else if (size == 1) { + last = newNode; + first.next = last; + last.perv = first; + } else { + Node temp = last; + last = newNode; + temp.next = last; + last.perv = temp; + } + size++; + } + + public void firstAdd(String s) { + Node newNode = new Node(null, null, s); + newNode.next = first; + first.perv = newNode; + first = newNode; + size++; + } + + public void lastAdd(String s) { + Node newNode = new Node(null, null, s); + newNode.perv = last; + last.next = newNode; + last = newNode; + size++; + } + +/* + public void insert(String s, int index) { + if (index == 1) { + firstAdd(s); + } else if (index == size) { + lastAdd(s); + } else { + Node newNode = new Node(null, null, s); + Node node = jump(index); + newNode.perv = node.perv; + newNode.next = node; + node.perv.next = newNode; + node.perv = newNode; + size++; + } + } + + public void delete(int position) { + Node node = jump(position); + node.perv.next = node.next; + node.next.perv = node.perv; + size--; + } + + public boolean findItem(String s) { + Node node = first; + for (int i = 1; i < size; i++) { + if (node.s.equals(s)) { + return true; + } else { + node = node.next; + } + } + return false; + } + + + public void copy(LinkedList linkedList) { + LinkedList list = new LinkedList(); + Node nowNode = linkedList.first; + for (int i = 1; i < linkedList.size; i++) { + list.add(nowNode.s); + } + clone(list); + } + + + public void clone(LinkedList linkedList) { + last.next = linkedList.first; + linkedList.first.perv = last; + last = linkedList.last; + size+=linkedList.size; + } + + + public Node jump(int position) { + if (position <= size && position > 0) { + Node node = first; + for (int i = 1; i < position; i++) { + node = node.next; + } + return node; + } else { + System.out.println("error..."); + } + return null; + } + + public Node find() { + if (size == 1) { + System.out.println("没有中间节点"); + } else if (size == 0) { + System.out.println("链表为空"); + } else { + if (size % 2 == 0) { + System.out.println("没有中间节点"); + } else { + return jump((size / 2) + 1); + } + } + return null; + } + + public void fz() { + LinkedList list = new LinkedList(); + for (int i = size; i >= 1; i--) { + list.add(jump(i).s); + } + first = list.first; + last = list.last; + } + + public int getSize() { + return size; + } +*/ + + + @Override + public String toString() { + Node node = first; + System.out.print("{"); + for (int i = 1; i <= size; i++) { + System.out.print(node.s); + System.out.print(", "); + node = node.next; + } + System.out.print("}"); + return null; + } + + /* + static class Node { + private Node perv; + private Node next; + private String s; + + public Node(Node perv, Node next, String s) { + this.perv = perv; + this.next = next; + this.s = s; + } + } +*/ +} +class Node{ + private Node perv; + private Node next; + private String s; + + public Node(Node perv, Node next, String s) { + this.perv = perv; + this.next = next; + this.s = s; + } +}