Skip to content

Commit 358bed9

Browse files
committed
Merge branch 'dev'
2 parents 3d38129 + 794aeb6 commit 358bed9

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

group20/404130810/src/com/coderising/array/ArrayUtil.java

+42-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.coderising.array;
22

3-
import java.util.Arrays;
4-
import java.util.Iterator;
3+
import java.util.ArrayList;
54
import java.util.List;
65

76
public class ArrayUtil {
@@ -32,14 +31,14 @@ public void reverseArray(int[] origin) {
3231
public int[] removeZero(int[] oldArray) {
3332
int zeroCount = 0;
3433
for (int i = 0; i < oldArray.length; i++) {
35-
if(oldArray[i] == 0){
36-
zeroCount ++;
34+
if (oldArray[i] == 0) {
35+
zeroCount++;
3736
}
3837
}
3938
int[] removedZeroArray = new int[oldArray.length - zeroCount];
40-
41-
for (int i = 0,j = 0; i < oldArray.length; i++,j++) {
42-
if(oldArray[i] == 0){
39+
40+
for (int i = 0, j = 0; i < oldArray.length; i++, j++) {
41+
if (oldArray[i] == 0) {
4342
j--;
4443
continue;
4544
}
@@ -58,6 +57,7 @@ public int[] removeZero(int[] oldArray) {
5857
*/
5958

6059
public int[] merge(int[] array1, int[] array2) {
60+
List<Integer> mergedArrayList = new ArrayList<>();
6161
return null;
6262
}
6363

@@ -71,7 +71,9 @@ public int[] merge(int[] array1, int[] array2) {
7171
* @return
7272
*/
7373
public int[] grow(int[] oldArray, int size) {
74-
return null;
74+
int[] resultArray = new int[oldArray.length + size];
75+
System.arraycopy(oldArray, 0, resultArray, 0, oldArray.length);
76+
return resultArray;
7577
}
7678

7779
/**
@@ -82,9 +84,18 @@ public int[] grow(int[] oldArray, int size) {
8284
* @return
8385
*/
8486
public int[] fibonacci(int max) {
87+
8588
return null;
8689
}
8790

91+
private static int fibonacciNum(int n) {
92+
if (n <= 2) {
93+
return 1;
94+
} else {
95+
return fibonacciNum(n - 1) + fibonacciNum(n - 2);
96+
}
97+
}
98+
8899
/**
89100
* 返回小于给定最大值max的所有素数数组 例如max = 23, 返回的数组为[2,3,5,7,11,13,17,19]
90101
*
@@ -113,13 +124,32 @@ public int[] getPerfectNumbers(int max) {
113124
* @return
114125
*/
115126
public String join(int[] array, String seperator) {
116-
return null;
127+
StringBuilder sb = new StringBuilder();
128+
for (int i = 0; i < array.length; i++) {
129+
sb.append(array[i]);
130+
if (i != array.length - 1) {
131+
sb.append(seperator);
132+
}
133+
}
134+
return sb.toString();
117135
}
118136

119137
public static void main(String[] args) {
120-
int[] origin = { 0, 1, 2, 0, 12 };
121-
new ArrayUtil().removeZero(origin);
122-
138+
/*
139+
* int[] origin = { 0, 1, 2, 0, 12 }; new
140+
* ArrayUtil().removeZero(origin);
141+
*/
142+
/*
143+
* int[] array1 = { 3, 5, 7, 8 }; int[] array2 = { 4, 5, 6, 7 }; new
144+
* ArrayUtil().merge(array1, array2);
145+
*/
146+
/*
147+
* int[] array = { 3, 8, 9, 10, 12 }; new ArrayUtil().grow(array, 9);
148+
*/
149+
/*
150+
* int[] array = { 3, 8, 9, 10, 12 }; String seperator = "-";
151+
* System.out.println(new ArrayUtil().join(array, seperator));
152+
*/
123153
}
124154

125155
}

group20/404130810/src/com/coderising/litestruts/Struts.java

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import java.util.List;
77
import java.util.Map;
88

9-
import org.w3c.dom.Node;
10-
119
import com.coderising.litestruts.utils.StrutsUtil;
1210
import com.coderising.litestruts.view.View;
1311

0 commit comments

Comments
 (0)