forked from onlyliuxin/coding2017
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from CHENTao-U/master
第一次作业【from 西安-秋】
- Loading branch information
Showing
16 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>2567012201learning</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
11 changes: 11 additions & 0 deletions
11
group27/2567012201/2567012201learning/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6 KB
group27/2567012201/2567012201learning/src/com/coding/DataStructure/.DS_Store
Binary file not shown.
54 changes: 54 additions & 0 deletions
54
group27/2567012201/2567012201learning/src/com/coding/DataStructure/ArrayList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.coding.DataStructure; | ||
|
||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public abstract class ArrayList implements List { | ||
|
||
private int size = 0; | ||
private static final int INCREMENT = 10; | ||
|
||
private Object[] elementData = new Object[100]; | ||
|
||
public void add(Object o) { | ||
|
||
if ((size + 1)>= 100) { | ||
throw new RuntimeException("数组越界异常"); | ||
} | ||
elementData[size] = 0; | ||
size++; | ||
} | ||
|
||
public void add(int index, Object o){ | ||
growLength(); | ||
System.arraycopy(elementData, index, elementData, index+1, size-index); | ||
elementData[index] = o; | ||
size++; | ||
} | ||
|
||
public Object get(int index){ | ||
return elementData[index]; | ||
} | ||
|
||
public Object remove(int index){ | ||
if (index > size) throw new IndexOutOfBoundsException("index: "+index+", size: "+size); | ||
Object retVal = elementData[index]; | ||
System.arraycopy(elementData, index+1, elementData, index, size-(index+1)); | ||
elementData[--size] = null; | ||
return retVal; | ||
} | ||
|
||
public int size(){ | ||
return this.size; | ||
} | ||
|
||
public Iterator iterator(){ | ||
return null; | ||
} | ||
private void growLength() { | ||
if (this.size == elementData.length) { | ||
elementData = Arrays.copyOf(elementData, elementData.length+INCREMENT); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
group27/2567012201/2567012201learning/src/com/coding/DataStructure/LinkedList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.coding.DataStructure; | ||
|
||
public class LinkedList { | ||
|
||
public void addLast(E o) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
group27/2567012201/2567012201learning/src/com/coding/DataStructure/Queue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.coding.DataStructure; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
public class Queue { | ||
private int size; | ||
private LinkedList list = new LinkedList(); | ||
|
||
public void enQueue(Object o){ | ||
list.addLast(o);; | ||
size++; | ||
} | ||
|
||
public Object deQueue(){ | ||
if(size<=0){ | ||
throw new NoSuchElementException(); | ||
} | ||
Object val = list.removeFirst(); | ||
size--; | ||
return val; | ||
} | ||
|
||
public boolean isEmpty(){ | ||
boolean flag = false; | ||
if(size >= 0){ | ||
flag = true; | ||
} | ||
return flag; | ||
} | ||
|
||
public int size(){ | ||
return size; | ||
} | ||
|
||
} | ||
|
41 changes: 41 additions & 0 deletions
41
group27/2567012201/2567012201learning/src/com/coding/DataStructure/Stack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.coding.DataStructure; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
public class Stack { | ||
private ArrayList elementData = new ArrayList(); | ||
private int size; | ||
|
||
public void push(Object o){ | ||
elementData.add(o); | ||
size++; | ||
} | ||
|
||
public Object pop(){ | ||
if(size<=0){ | ||
throw new NoSuchElementException(); | ||
} | ||
int len = size-1; | ||
Object val = elementData.remove(len); | ||
size--; | ||
return val; | ||
} | ||
|
||
public Object peek(){ | ||
if(size<=0){ | ||
throw new NoSuchElementException(); | ||
} | ||
int len = size-1; | ||
return elementData.get(len); | ||
} | ||
public boolean isEmpty(){ | ||
boolean flag = false; | ||
if(size >= 0){ | ||
flag = true; | ||
} | ||
return flag; | ||
} | ||
public int size(){ | ||
return size; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
group27/2567012201/2567012201learning/src/com/coding/DataStructure/Tree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.coding.DataStructure; | ||
|
||
public class Tree { | ||
private Object data; | ||
private Tree left; | ||
private Tree right; | ||
|
||
public Object getData() { | ||
return data; | ||
} | ||
|
||
public void setData(Object data) { | ||
this.data = data; | ||
} | ||
|
||
public Tree getLeft() { | ||
return left; | ||
} | ||
|
||
public void setLeft(Tree left) { | ||
this.left = left; | ||
} | ||
|
||
public Tree getRight() { | ||
return right; | ||
} | ||
|
||
public void setRight(Tree right) { | ||
this.right = right; | ||
} | ||
|
||
public Tree insert(Object o) { | ||
if (data == null) { | ||
setData(o); | ||
} else { | ||
Integer i = (Integer) o; | ||
if (i.compareTo((Integer) data) == -1) { | ||
if(right == null) | ||
right = new Tree(); | ||
return right.insert(i); | ||
} else if (i.compareTo((Integer) data) == 1) { | ||
if(left == null) | ||
left = new Tree(); | ||
return left.insert(i); | ||
} | ||
return null; | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>RemoteSystemsTempFiles</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature> | ||
</natures> | ||
</projectDescription> |