diff --git a/.gitignore b/.gitignore
index 8b13789179..d749cfbd62 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,21 @@
-
+*.class
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+#ide config
+.metadata
+.recommenders
+.idea/
+*.iml
+rebel.*
+.rebel.*
+
+target
diff --git a/.project b/.project
new file mode 100644
index 0000000000..6b4d50ed9a
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ coding2017
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000..4824b80263
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/array/ArrayUtil.java b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/array/ArrayUtil.java
new file mode 100644
index 0000000000..38c0889f32
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/array/ArrayUtil.java
@@ -0,0 +1,301 @@
+package com.github.Ven13.coding2017.array;
+
+public class ArrayUtil {
+
+ /**
+ * 给定一个整形数组a , 对该数组的值进行置换
+ 例如: a = [7, 9 , 30, 3] , 置换后为 [3, 30, 9,7]
+ 如果 a = [7, 9, 30, 3, 4] , 置换后为 [4,3, 30 , 9,7]
+ * @param origin
+ * @return
+ */
+ public void reverseArray(int[] origin){
+
+ int originalLen = origin.length;
+
+ int len = originalLen;
+
+ int temp;
+
+ for(int i = 0; i < (originalLen/2); i++){
+
+ temp = origin[len - i - 1];
+
+ origin[len - i - 1] = origin[i];
+
+ origin[i] = temp;
+
+ }
+ }
+
+ /**
+ * 现在有如下的一个数组: int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5}
+ * 要求将以上数组中值为0的项去掉,将不为0的值存入一个新的数组,生成的新数组为:
+ * {1,3,4,5,6,6,5,4,7,6,7,5}
+ * @param oldArray
+ * @return
+ */
+
+ public int[] removeZero(int[] oldArray){
+
+ // 定意新数组长度变量
+ int newLength = 0;
+ // 获得新数组长度值
+ for (int i = 0; i < oldArray.length; i++) {
+
+ if(oldArray[i] != 0) {
+
+ newLength++;
+
+ }
+
+ }
+
+ // 定意新数组
+ int[] newArray = new int[newLength];
+ // 定意新数组下标变量
+ int n = 0;
+ // 转存数组
+ for (int i = 0; i < oldArray.length; i++) {
+
+ if(oldArray[i] != 0) {
+
+ newArray[n] = oldArray[i];// 转存数组
+ n++;// 新数组下标偏移
+
+ }
+
+ }
+
+ //返回生成的新数组
+ return newArray;
+
+ }
+
+ /**
+ * 给定两个已经排序好的整形数组, a1和a2 , 创建一个新的数组a3, 使得a3 包含a1和a2 的所有元素, 并且仍然是有序的
+ * 例如 a1 = [3, 5, 7,8] a2 = [4, 5, 6,7] 则 a3 为[3,4,5,6,7,8] , 注意: 已经消除了重复
+ * @param array1
+ * @param array2
+ * @return
+ */
+
+ public int[] merge(int[] array1, int[] array2){
+
+ int[] newArray = new int[array1.length + array2.length];
+
+ int k = 0;
+
+ String inNum = "";
+
+ for(int i = 0; i < array1.length; i++) {
+
+ for(int j = 0; j < array2.length; j++) {
+
+ if (array1[i] < array2[j]) {
+ if (inNum.indexOf(array1[i] + "|") < 0) {
+ newArray[k++] = array1[i];
+ inNum += array1[i] + "|";
+ }
+
+ } else if (array1[i] == array2[j]) {
+ if (inNum.indexOf(array1[i] + "|") < 0) {
+ newArray[k++] = array1[i];
+ inNum += array1[i] + "|";
+ }
+ } else {
+ if (i == array1.length - 1) {
+ if (inNum.indexOf(array1[i] + "|") < 0) {
+ newArray[k++] = array1[i];
+ inNum += array1[i] + "|";
+ }
+ } else {
+ if (inNum.indexOf(array2[j] + "|") < 0) {
+ newArray[k++] = array2[j];
+ inNum += array2[j] + "|";
+ }
+ }
+
+ }
+
+ }
+
+ }
+
+ return newArray;
+ }
+ /**
+ * 把一个已经存满数据的数组 oldArray的容量进行扩展, 扩展后的新数据大小为oldArray.length + size
+ * 注意,老数组的元素在新数组中需要保持
+ * 例如 oldArray = [2,3,6] , size = 3,则返回的新数组为
+ * [2,3,6,0,0,0]
+ * @param oldArray
+ * @param size
+ * @return
+ */
+ public int[] grow(int [] oldArray, int size){
+ int[] newArray = new int[oldArray.length + size];
+ return newArray;
+ }
+
+ /**
+ * 斐波那契数列为:1,1,2,3,5,8,13,21...... ,给定一个最大值, 返回小于该值的数列
+ * 例如, max = 15 , 则返回的数组应该为 [1,1,2,3,5,8,13]
+ * max = 1, 则返回空数组 []
+ * @param max
+ * @return
+ */
+ public int[] fibonacci(int max){
+ return null;
+ }
+
+ /**
+ * 返回小于给定最大值max的所有素数数组
+ * 例如max = 23, 返回的数组为[2,3,5,7,11,13,17,19]
+ * @param max
+ * @return
+ */
+ public int[] getPrimes(int max){
+
+ int[] newArray = new int[max];
+
+ int k = 0;
+
+ boolean isN = true;
+
+ if (max > 2) {
+
+ for (int i = 2; i < max; i++) {
+
+ isN = true;
+
+ for (int j = 2; j < max; j++) {
+
+ if (i % j == 0 && i != j) {
+
+ isN = false;
+
+ }
+ }
+
+ if (isN) {
+
+ newArray[k++] = i;
+
+ }
+
+ }
+
+ } else if (max == 2) {
+
+ newArray[0] = 2;
+ k++;
+ } else {
+
+ return null;
+
+ }
+
+ int[] newArray2 = new int[k];
+
+ for(int i = 0; i < k; i ++) {
+
+ newArray2[i] = newArray[i];
+
+ }
+
+ return newArray2;
+ }
+
+ /**
+ * 所谓“完数”, 是指这个数恰好等于它的因子之和,例如6=1+2+3
+ * 给定一个最大值max, 返回一个数组, 数组中是小于max 的所有完数
+ * @param max
+ * @return
+ */
+ public int[] getPerfectNumbers(int max) {
+
+ int i, j, k;
+
+ int sum;
+
+ k = 0;
+
+ for(i = 1; i <= max; i++) {
+
+
+ sum = 0;
+
+ for(j = 1; j < i; j++) {
+
+ if(i % j == 0) {
+
+ sum += j;
+
+ }
+
+ }
+
+ if(i == sum)
+ k++;
+ }
+
+ int[] newArray = new int[k];
+
+ k = 0;
+
+ for(i = 1; i <= max; i++) {
+
+
+ sum = 0;
+
+ for(j = 1; j < i; j++) {
+
+ if(i % j == 0) {
+
+ sum += j;
+
+ }
+
+ }
+
+ if(i == sum) {
+
+ newArray[k] = i;
+
+ k++;
+
+ }
+
+ }
+
+
+ return newArray;
+ }
+
+ /**
+ * 用seperator 把数组 array给连接起来
+ * 例如array= [3,8,9], seperator = "-"
+ * 则返回值为"3-8-9"
+ * @param array
+ * @param s
+ * @return
+ */
+ public String join(int[] array, String seperator){
+
+ String str = "";
+
+ for(int i = 0; i < array.length; i++) {
+
+ str += array[i] + seperator;
+
+ }
+
+ str = str.substring(0, str.length() - 1);
+
+ return str;
+ }
+
+
+
+}
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/array/test/ArrayUtilTest.java b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/array/test/ArrayUtilTest.java
new file mode 100644
index 0000000000..c9684fa326
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/array/test/ArrayUtilTest.java
@@ -0,0 +1,46 @@
+package com.github.Ven13.coding2017.array.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.github.Ven13.coding2017.array.ArrayUtil;
+
+public class ArrayUtilTest {
+
+ @Test
+ public final void testMerge() {
+ ArrayUtil arrayUtil = new ArrayUtil();
+ int[] a1 = {3, 5, 7, 8};
+ int[] a2 = {4, 5, 6, 7};
+ int[] a3 = {};
+ a3 = arrayUtil.merge(a1, a2);
+ assertEquals(3, a3[0]);
+ assertEquals(4, a3[1]);
+ assertEquals(5, a3[2]);
+ assertEquals(6, a3[3]);
+ assertEquals(7, a3[4]);
+ assertEquals(8, a3[5]);
+
+ }
+
+ @Test
+ public final void testgetPrimes() {
+ ArrayUtil arrayUtil = new ArrayUtil();
+ int max = 23;
+ int[] a1 = {};
+ a1 = arrayUtil.getPrimes(max);
+ assertEquals(3, a1.length);
+ assertEquals(1, a1[0]);
+ assertEquals(2, a1[1]);
+ assertEquals(3, a1[2]);
+ }
+
+ @Test
+ public final void testgetPerfectNumbers() {
+ ArrayUtil arrayUtil = new ArrayUtil();
+ int max = 6;
+ int[] a1 = {};
+ a1 = arrayUtil.getPerfectNumbers(max);
+ }
+}
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/LoginAction.java b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/LoginAction.java
new file mode 100644
index 0000000000..d43bc2c452
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/LoginAction.java
@@ -0,0 +1,42 @@
+package com.github.Ven13.coding2017.litestruts;
+
+/**
+ * 杩欐槸涓涓敤鏉ュ睍绀虹櫥褰曠殑涓氬姟绫伙紝 鍏朵腑鐨勭敤鎴峰悕鍜屽瘑鐮侀兘鏄‖缂栫爜鐨勩
+ * @author liuxin
+ *
+ */
+public class LoginAction{
+ private String name ;
+ private String password;
+ private String message;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String execute(){
+ if("test".equals(name) && "1234".equals(password)){
+ this.message = "login successful";
+ return "success";
+ }
+ this.message = "login failed,please check your user/pwd";
+ return "fail";
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+ public void setPassword(String password){
+ this.password = password;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ public String getMessage(){
+ return this.message;
+ }
+}
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/Struts.java b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/Struts.java
new file mode 100644
index 0000000000..a9040e257d
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/Struts.java
@@ -0,0 +1,166 @@
+package com.github.Ven13.coding2017.litestruts;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.io.File;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+
+
+
+public class Struts {
+
+ public static View runAction(String actionName, Map parameters) {
+
+ /*
+
+ 0. 璇诲彇閰嶇疆鏂囦欢struts.xml
+
+ 1. 鏍规嵁actionName鎵惧埌鐩稿搴旂殑class 锛 渚嬪LoginAction, 閫氳繃鍙嶅皠瀹炰緥鍖栵紙鍒涘缓瀵硅薄锛
+ 鎹畃arameters涓殑鏁版嵁锛岃皟鐢ㄥ璞$殑setter鏂规硶锛 渚嬪parameters涓殑鏁版嵁鏄
+ ("name"="test" , "password"="1234") ,
+ 閭e氨搴旇璋冪敤 setName鍜宻etPassword鏂规硶
+
+ 2. 閫氳繃鍙嶅皠璋冪敤瀵硅薄鐨別xectue 鏂规硶锛 骞惰幏寰楄繑鍥炲硷紝渚嬪"success"
+
+ 3. 閫氳繃鍙嶅皠鎵惧埌瀵硅薄鐨勬墍鏈塯etter鏂规硶锛堜緥濡 getMessage锛,
+ 閫氳繃鍙嶅皠鏉ヨ皟鐢紝 鎶婂煎拰灞炴у舰鎴愪竴涓狧ashMap , 渚嬪 {"message": "鐧诲綍鎴愬姛"} ,
+ 鏀惧埌View瀵硅薄鐨刾arameters
+
+ 4. 鏍规嵁struts.xml涓殑 閰嶇疆,浠ュ強execute鐨勮繑鍥炲硷紝 纭畾鍝竴涓猨sp锛
+ 鏀惧埌View瀵硅薄鐨刯sp瀛楁涓
+
+ */
+
+ View view = new View();
+
+ Map map = testParseXmlData(actionName, "/struts.xml");
+
+ String className = (String)map.get(actionName);
+
+ String resultName = "";
+ System.out.println(className);
+
+ try {
+ Class c = Class.forName(className);
+ Object obj = c.newInstance();
+ Method method = null;
+
+ for (Map.Entry entry : parameters.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ PropertyDescriptor pd = new PropertyDescriptor(key, c);
+ Method setMethod = pd.getWriteMethod();
+ setMethod.invoke(obj, value);
+ }
+
+ Method exec = c.getDeclaredMethod("execute");
+ Object res = exec.invoke(obj);
+ if(res != null) {
+ resultName = (String)map.get(actionName + '|' + res);
+ view.setJsp(resultName);
+ }
+ Field[] fields = c.getDeclaredFields();
+ for(Field f : fields){
+ PropertyDescriptor descriptor = new PropertyDescriptor(f.getName(), c);
+ Method getMethod = descriptor.getReadMethod();
+ Object value = getMethod.invoke(obj);
+ parameters.put(f.getName(), (String)value);
+ }
+ view.setParameters(parameters);
+
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (IntrospectionException e) {
+ System.out.println(e.toString());
+ e.printStackTrace();
+ }
+
+
+ return view;
+ }
+
+ public static Document parse2Document(String xmlFilePath){
+ SAXReader reader = new SAXReader();
+ Document doc = null;
+ try {
+ InputStream inputStream = Class.class.getResourceAsStream(xmlFilePath);
+ doc = reader.read(inputStream);
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ }
+ return doc;
+ }
+
+ public static Map testParseXmlData(String actionName, String xmlFilePath){
+ //鑾峰彇xml瑙f瀽鍣ㄥ璞
+ //SAXReader reader = new SAXReader();
+ //灏唜ml瑙f瀽涓篋ocument瀵硅薄
+ Document doc = parse2Document(xmlFilePath);
+ //鑾峰彇鏂囨。鐨勬牴鍏冪礌
+ Element root = doc.getRootElement();
+
+ //瀹氫箟淇濆瓨灞炴с佸肩殑map
+ Map map = new HashMap();
+
+
+ //閬嶅巻褰撳墠鍏冪礌(鍦ㄦ鏄牴鍏冪礌)鐨勫瓙鍏冪礌
+
+ for (Iterator i_pe = root.elementIterator(); i_pe.hasNext();) {
+
+ Element e_pe = (Element) i_pe.next();
+ //鑾峰彇褰撳墠鍏冪礌鐨勫悕瀛
+ String act = e_pe.getName();
+ //鑾峰彇褰撳墠鍏冪礌鐨刵ame鍜宑lass灞炴х殑鍊煎苟鍒嗗埆璧嬬粰attName,attClass鍙橀噺
+ System.out.println(act);
+ String attName = e_pe.attributeValue("name");
+ String attClass = e_pe.attributeValue("class");
+ if (attName.equals(actionName)) {
+ map.put(attName, attClass);
+
+ //Element e_res = e_pe.element("result");
+ //System.out.println(e_res.getName());
+ for (Iterator i_res = e_pe.elementIterator(); i_res.hasNext();) {
+
+ Element e_re = (Element) i_res.next();
+ //鑾峰彇褰撳墠鍏冪礌鐨勫悕瀛
+ String person_n = e_re.getName();
+ //鑾峰彇褰撳墠鍏冪礌鐨刵ame鍜宑lass灞炴х殑鍊煎苟鍒嗗埆璧嬬粰attName,attClass鍙橀噺
+ System.out.println(person_n);
+ String resName = e_re.attributeValue("name");
+ String resClass = e_re.getStringValue();
+ map.put(attName + '|' + resName, resClass);
+
+ }
+ }
+ }
+
+ return map;
+
+ }
+
+}
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/StrutsTest.java b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/StrutsTest.java
new file mode 100644
index 0000000000..a5a777be1c
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/StrutsTest.java
@@ -0,0 +1,43 @@
+package com.github.Ven13.coding2017.litestruts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+
+public class StrutsTest {
+
+ @Test
+ public void testLoginActionSuccess() {
+
+ String actionName = "login";
+
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","1234");
+
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/homepage.jsp", view.getJsp());
+ Assert.assertEquals("login successful", view.getParameters().get("message"));
+ }
+
+ @Test
+ public void testLoginActionFailed() {
+ String actionName = "login";
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","123456"); //鐎靛棛鐖滈崪宀勵暕鐠佸墽娈戞稉宥勭閼凤拷
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp());
+ Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message"));
+ }
+}
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/View.java b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/View.java
new file mode 100644
index 0000000000..2b0997095c
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/View.java
@@ -0,0 +1,23 @@
+package com.github.Ven13.coding2017.litestruts;
+
+import java.util.Map;
+
+public class View {
+ private String jsp;
+ private Map parameters;
+
+ public String getJsp() {
+ return jsp;
+ }
+ public View setJsp(String jsp) {
+ this.jsp = jsp;
+ return this;
+ }
+ public Map getParameters() {
+ return parameters;
+ }
+ public View setParameters(Map parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+}
diff --git a/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/struts.xml b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/struts.xml
new file mode 100644
index 0000000000..59ec89bb69
--- /dev/null
+++ b/group02/106614649/106614649Learnin/src/com/github/Ven13/coding2017/litestruts/struts.xml
@@ -0,0 +1,11 @@
+
+
+
+ /jsp/homepage.jsp
+ /jsp/showLogin.jsp
+
+
+ /jsp/welcome.jsp
+ /jsp/error.jsp
+
+
\ No newline at end of file
diff --git a/group05/1094051862/test01/src/com/coding/basic/.gitignore b/group02/106614649/106614649Learnin/src/struts.xml
similarity index 100%
rename from group05/1094051862/test01/src/com/coding/basic/.gitignore
rename to group02/106614649/106614649Learnin/src/struts.xml
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/array/ArrayUtil.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/array/ArrayUtil.java
new file mode 100644
index 0000000000..f60be05977
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/array/ArrayUtil.java
@@ -0,0 +1,228 @@
+package com.github.FelixCJF.coding2017.coderising.array;
+
+import java.util.ArrayList;
+
+public class ArrayUtil {
+
+ /**
+ * 缁欏畾涓涓暣褰㈡暟缁刟 , 瀵硅鏁扮粍鐨勫艰繘琛岀疆鎹
+ 渚嬪锛 a = [7, 9 , 30, 3] , 缃崲鍚庝负 [3, 30, 9,7]
+ 濡傛灉 a = [7, 9, 30, 3, 4] , 缃崲鍚庝负 [4,3, 30 , 9,7]
+ * @param origin
+ * @return
+ */
+ public void reverseArray(int[] origin){
+ int array[] = new int[origin.length];
+ for (int i = 0; i newArr[i+1]) {
+ int temp = newArr[i];
+ newArr[i] = newArr[i+1];
+ newArr[i + 1] = temp;
+ }
+ }
+ return newArr;
+ }
+ /**
+ * 鎶婁竴涓凡缁忓瓨婊℃暟鎹殑鏁扮粍 oldArray鐨勫閲忚繘琛屾墿灞曪紝 鎵╁睍鍚庣殑鏂版暟鎹ぇ灏忎负oldArray.length + size
+ * 娉ㄦ剰锛岃佹暟缁勭殑鍏冪礌鍦ㄦ柊鏁扮粍涓渶瑕佷繚鎸
+ * 渚嬪 oldArray = [2,3,6] , size = 3,鍒欒繑鍥炵殑鏂版暟缁勪负
+ * [2,3,6,0,0,0]
+ * @param oldArray
+ * @param size
+ * @return
+ */
+ public int[] grow(int [] oldArray, int size){
+ int newArr[] = new int[oldArray.length + size];
+ System.arraycopy(oldArray, 0, newArr, 0, oldArray.length);
+ return newArr;
+ }
+
+ /**
+ * 鏂愭尝閭e鏁板垪涓猴細1锛1锛2锛3锛5锛8锛13锛21...... 锛岀粰瀹氫竴涓渶澶у硷紝 杩斿洖灏忎簬璇ュ肩殑鏁板垪
+ * 渚嬪锛 max = 15 , 鍒欒繑鍥炵殑鏁扮粍搴旇涓 [1锛1锛2锛3锛5锛8锛13]
+ * max = 1, 鍒欒繑鍥炵┖鏁扮粍 []
+ * @param max
+ * @return
+ */
+ public int[] fibonacci(int max){
+ int[] newArr;
+ int f1 = 0;
+ int f2 = 1;
+ int f = 0;
+ if (max < 2) {
+ return newArr = new int[0];
+ }
+ ArrayList list = new ArrayList();
+ for (int i = 2; f < max; i++) {
+ list.add(f2);
+ f = f1 + f2;
+ f1 = f2;
+ f2 = f;
+ }
+ newArr = new int[list.size()];
+ for (int i = 0; i < newArr.length; i++) {
+ newArr[i] = (int) list.get(i);
+ }
+ return newArr;
+ }
+
+ /**
+ * 杩斿洖灏忎簬缁欏畾鏈澶у糾ax鐨勬墍鏈夌礌鏁版暟缁
+ * 渚嬪max = 23, 杩斿洖鐨勬暟缁勪负[2,3,5,7,11,13,17,19]
+ * @param max
+ * @return
+ */
+ public int[] getPrimes(int max){
+
+ ArrayList list = new ArrayList();
+
+ for (int i = 1; i < max; i++) {
+ if (isPrime(i)) {
+ list.add(i);
+ }
+ }
+ int[] newArr = new int[list.size()];
+ for (int i = 0; i < newArr.length; i++) {
+ newArr[i] = (int) list.get(i);
+ }
+ return newArr;
+ }
+ //鍒ゆ柇鏄惁涓虹礌鏁
+ private boolean isPrime(int a) {
+
+ boolean flag = true;
+
+ if (a < 2) {// 绱犳暟涓嶅皬浜2
+ return false;
+ } else {
+
+ for (int i = 2; i <= Math.sqrt(a); i++) {
+
+ if (a % i == 0) {// 鑻ヨ兘琚暣闄わ紝鍒欒鏄庝笉鏄礌鏁帮紝杩斿洖false
+
+ flag = false;
+ break;// 璺冲嚭寰幆
+ }
+ }
+ }
+ return flag;
+ }
+
+ /**
+ * 鎵璋撯滃畬鏁扳濓紝 鏄寚杩欎釜鏁版伆濂界瓑浜庡畠鐨勫洜瀛愪箣鍜岋紝渚嬪6=1+2+3
+ * 缁欏畾涓涓渶澶у糾ax锛 杩斿洖涓涓暟缁勶紝 鏁扮粍涓槸灏忎簬max 鐨勬墍鏈夊畬鏁
+ * @param max
+ * @return
+ */
+ public int[] getPerfectNumbers(int max){
+ int[] newArr;
+ if (max == 0) {
+ return newArr = new int[0];
+ }
+ ArrayList list = new ArrayList();
+ for (int i = 1; i < max; i++) {
+ if (isWanshu(i)) {
+ list.add(i);
+ }
+ }
+ newArr = new int[list.size()];
+ for (int i = 0; i < newArr.length; i++) {
+ newArr[i] = (int) list.get(i);
+ }
+ return newArr;
+ }
+ //鍒ゆ柇涓涓暟鏄笉鏄畬鏁
+ private boolean isWanshu(int n)
+ {
+ boolean flag=false;
+ int i,sum=0;
+ for(i=1;i<=n/2;i++)
+ {
+ if(n%i==0)
+ {
+ sum+=i;
+ }
+ }
+ if(sum==n)
+ {
+ flag=true;
+ }
+ return flag;
+ }
+ /**
+ * 鐢╯eperator 鎶婃暟缁 array缁欒繛鎺ヨ捣鏉
+ * 渚嬪array= [3,8,9], seperator = "-"
+ * 鍒欒繑鍥炲间负"3-8-9"
+ * @param array
+ * @param s
+ * @return
+ */
+ public String join(int[] array, String seperator){
+ String string = "";
+ for (int i = 0; i < array.length; i++) {
+ if (i == array.length - 1) {
+ string += array[i];
+ } else {
+ string += array[i] + seperator;
+ }
+ }
+ return string;
+ }
+
+
+}
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/array/test/ArrayUtilTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/array/test/ArrayUtilTest.java
new file mode 100644
index 0000000000..378e052164
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/array/test/ArrayUtilTest.java
@@ -0,0 +1,148 @@
+package com.github.FelixCJF.coding2017.coderising.array.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import com.github.FelixCJF.coding2017.coderising.array.ArrayUtil;
+
+
+public class ArrayUtilTest
+{
+ private ArrayUtil myArray;
+ @Before
+ public void setUp() throws Exception
+ {
+ myArray = new ArrayUtil();
+ }
+
+ @Test
+ public void testReverseArray()
+ {
+ int[] a = {1, 2, 1, 3, 5, 6};
+ int[] b = {6, 5, 3, 1, 2, 1};
+ int[] c = new int[0];
+
+ myArray.reverseArray(a);
+ assertArrayEquals(a, b);
+
+ //瀵圭┖鏁扮粍杩涜鍙嶈浆
+ myArray.reverseArray(c);
+ assertArrayEquals(c, new int[0]);
+ }
+
+ @Test
+ public void testRemoveZero()
+ {
+ int[] oldArr= {1, 3, 4, 5, 0, 0, 6, 6, 0, 5, 4, 7, 6, 7, 1, 2, 0, 5};
+ int b[] = {1, 3, 4, 5, 6, 6, 5, 4, 7, 6, 7, 1, 2, 5};
+ int[] c = myArray.removeZero(oldArr);
+ assertArrayEquals(b, c);
+
+ int[] d = new int[0];
+ assertArrayEquals(d, new int[0]);
+ }
+
+ @Test
+ public void testMerge()
+ {
+ int a1[] = {1, 2, 3, 4, 5};
+ int b1[] = {3, 4, 5, 6, 7, 8};
+ int c1[] = {1, 2, 3, 4, 5, 6, 7, 8};
+ int[] newArray1 = myArray.merge(a1, b1);
+ assertArrayEquals(c1, newArray1);
+
+ int a2[] = new int[0];
+ int b2[] = {0, 2, 3, 6, 7, 8};
+ int c2[] = {0, 2, 3, 6, 7, 8};
+ int[] newArray2 = myArray.merge(a2, b2);
+ assertArrayEquals(c2, newArray2);
+
+ int a3[] = {0, 2, 3, 6, 7, 8};
+ int b3[] = new int[0];
+ int c3[] = {0, 2, 3, 6, 7, 8};
+ int[] newArray3 = myArray.merge(a3, b3);
+ assertArrayEquals(c3, newArray3);
+
+ int[] a4 = new int[0];
+ int[] b4 = new int[0];
+ int[] newArray4 = myArray.merge(a4, b4);
+ assertArrayEquals(new int[0], newArray4);
+ }
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+ @Test
+ public void testGrow()
+ {
+ int[] a = {3, 5, 7, 8, 9};
+ int[] b = {3, 5, 7, 8, 9, 0, 0, 0};
+ int[] newArray = myArray.grow(a, 3);
+ assertArrayEquals(b, newArray);
+
+ // size < 0 鎶涘嚭寮傚父
+ expectedEx.expect(Exception.class);
+ int[] newArray1 = myArray.grow(a, -3);
+ assertArrayEquals(b, newArray1);
+
+ }
+
+ @Test
+ public void testFibonacci()
+ {
+ //max == 1鏃惰繑鍥炵┖鏁扮粍
+ int[] array1 = myArray.fibonacci(1);
+ int[] b = new int[0];
+ assertArrayEquals(array1, b);
+
+
+ int[] array2= myArray.fibonacci(35);
+ int[] c = {1, 1, 2, 3, 5, 8, 13, 21, 34 };
+ assertArrayEquals(c, array2);
+ }
+
+ @Test
+ public void testGetPrimes()
+ {
+ int[] a = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
+ int[] array1 = myArray.getPrimes(35);
+ assertArrayEquals(a, array1);
+
+ //max <= 2鐨勬椂鍊欐病鏈夌礌鏁帮紝鏁扮粍涓虹┖鏁扮粍 new int[0]
+ int[] array2 = myArray.getPrimes(1);
+ int[] b = new int[0];
+ assertArrayEquals(array2, b);
+ }
+
+ @Test
+ public void testGetPerfectNumbers()
+ {
+ int[] array = myArray.getPerfectNumbers(10000);
+ int[] a = {6, 28, 496, 8128 };
+ assertArrayEquals(a, array);
+ }
+
+ @Test
+ public void testJoin()
+ {
+ int[] Array0 = {3, 5, 7, 8, 9};
+ String s0 = myArray.join(Array0, "-");
+ String s1 = "3-5-7-8-9";
+ assertEquals(s1, s0);
+
+ int[] Array1 = {3};
+ String s2 = myArray.join(Array1, "-");
+ String s3 = "3";
+ assertEquals(s2, s3);
+
+ //浼犻掔┖鏁扮粍鏃讹紝杩斿洖绌烘暟缁
+ int[] Array2 = new int[0];
+ String s4 = myArray.join(Array2, "-");
+ String s5 = "";
+ assertEquals(s4, s5);
+ }
+
+}
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/LoginAction.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/LoginAction.java
new file mode 100644
index 0000000000..dcdbe226ed
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/LoginAction.java
@@ -0,0 +1,39 @@
+package com.coderising.litestruts;
+
+/**
+ * 杩欐槸涓涓敤鏉ュ睍绀虹櫥褰曠殑涓氬姟绫伙紝 鍏朵腑鐨勭敤鎴峰悕鍜屽瘑鐮侀兘鏄‖缂栫爜鐨勩
+ * @author liuxin
+ *
+ */
+public class LoginAction{
+ private String name ;
+ private String password;
+ private String message;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String execute(){
+ if("test".equals(name) && "1234".equals(password)){
+ this.message = "login successful";
+ return "success";
+ }
+ this.message = "login failed,please check your user/pwd";
+ return "fail";
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+ public void setPassword(String password){
+ this.password = password;
+ }
+ public String getMessage(){
+ return this.message;
+ }
+}
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/Struts.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/Struts.java
new file mode 100644
index 0000000000..85e2e22de3
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/Struts.java
@@ -0,0 +1,34 @@
+package com.coderising.litestruts;
+
+import java.util.Map;
+
+
+
+public class Struts {
+
+ public static View runAction(String actionName, Map parameters) {
+
+ /*
+
+ 0. 璇诲彇閰嶇疆鏂囦欢struts.xml
+
+ 1. 鏍规嵁actionName鎵惧埌鐩稿搴旂殑class 锛 渚嬪LoginAction, 閫氳繃鍙嶅皠瀹炰緥鍖栵紙鍒涘缓瀵硅薄锛
+ 鎹畃arameters涓殑鏁版嵁锛岃皟鐢ㄥ璞$殑setter鏂规硶锛 渚嬪parameters涓殑鏁版嵁鏄
+ ("name"="test" , "password"="1234") ,
+ 閭e氨搴旇璋冪敤 setName鍜宻etPassword鏂规硶
+
+ 2. 閫氳繃鍙嶅皠璋冪敤瀵硅薄鐨別xectue 鏂规硶锛 骞惰幏寰楄繑鍥炲硷紝渚嬪"success"
+
+ 3. 閫氳繃鍙嶅皠鎵惧埌瀵硅薄鐨勬墍鏈塯etter鏂规硶锛堜緥濡 getMessage锛,
+ 閫氳繃鍙嶅皠鏉ヨ皟鐢紝 鎶婂煎拰灞炴у舰鎴愪竴涓狧ashMap , 渚嬪 {"message": "鐧诲綍鎴愬姛"} ,
+ 鏀惧埌View瀵硅薄鐨刾arameters
+
+ 4. 鏍规嵁struts.xml涓殑 閰嶇疆,浠ュ強execute鐨勮繑鍥炲硷紝 纭畾鍝竴涓猨sp锛
+ 鏀惧埌View瀵硅薄鐨刯sp瀛楁涓
+
+ */
+
+ return null;
+ }
+
+}
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/StrutsTest.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/StrutsTest.java
new file mode 100644
index 0000000000..b8c81faf3c
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/StrutsTest.java
@@ -0,0 +1,43 @@
+package com.coderising.litestruts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+
+public class StrutsTest {
+
+ @Test
+ public void testLoginActionSuccess() {
+
+ String actionName = "login";
+
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","1234");
+
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/homepage.jsp", view.getJsp());
+ Assert.assertEquals("login successful", view.getParameters().get("message"));
+ }
+
+ @Test
+ public void testLoginActionFailed() {
+ String actionName = "login";
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","123456"); //瀵嗙爜鍜岄璁剧殑涓嶄竴鑷
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp());
+ Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message"));
+ }
+}
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/View.java b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/View.java
new file mode 100644
index 0000000000..07df2a5dab
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/View.java
@@ -0,0 +1,23 @@
+package com.coderising.litestruts;
+
+import java.util.Map;
+
+public class View {
+ private String jsp;
+ private Map parameters;
+
+ public String getJsp() {
+ return jsp;
+ }
+ public View setJsp(String jsp) {
+ this.jsp = jsp;
+ return this;
+ }
+ public Map getParameters() {
+ return parameters;
+ }
+ public View setParameters(Map parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+}
diff --git a/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/struts.xml b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/struts.xml
new file mode 100644
index 0000000000..a6cfe43e6c
--- /dev/null
+++ b/group02/1554421063/src/com/github/FelixCJF/coding2017/coderising/litestruts/struts.xml
@@ -0,0 +1,11 @@
+
+
+
+ /jsp/homepage.jsp
+ /jsp/showLogin.jsp
+
+
+ /jsp/welcome.jsp
+ /jsp/error.jsp
+
+
\ No newline at end of file
diff --git a/group02/527705641/src/com/github/fei9009/coderising0226/array/ArrayUtil.java b/group02/527705641/src/com/github/fei9009/coderising0226/array/ArrayUtil.java
new file mode 100644
index 0000000000..d4e62075d9
--- /dev/null
+++ b/group02/527705641/src/com/github/fei9009/coderising0226/array/ArrayUtil.java
@@ -0,0 +1,218 @@
+package com.github.fei9009.coderising0226.array;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import com.sun.org.apache.bcel.internal.generic.ISTORE;
+
+public class ArrayUtil {
+
+ /**
+ * 缁欏畾涓涓暣褰㈡暟缁刟 , 瀵硅鏁扮粍鐨勫艰繘琛岀疆鎹
+ 渚嬪锛 a = [7, 9 , 30, 3] , 缃崲鍚庝负 [3, 30, 9,7]
+ 濡傛灉 a = [7, 9, 30, 3, 4] , 缃崲鍚庝负 [4,3, 30 , 9,7]
+ * @param origin
+ * @return
+ */
+ public void reverseArray(int[] origin){
+ int i = 0, j = origin.length-1;
+ while(i < j){
+ int tmp = origin[i];
+ origin[i] = origin[j];
+ origin[j] = tmp;
+ i++;
+ j--;
+ }
+ }
+
+ /**
+ * 鐜板湪鏈夊涓嬬殑涓涓暟缁勶細 int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5}
+ * 瑕佹眰灏嗕互涓婃暟缁勪腑鍊间负0鐨勯」鍘绘帀锛屽皢涓嶄负0鐨勫煎瓨鍏ヤ竴涓柊鐨勬暟缁勶紝鐢熸垚鐨勬柊鏁扮粍涓猴細
+ * {1,3,4,5,6,6,5,4,7,6,7,5}
+ * @param oldArray
+ * @return
+ */
+
+ public int[] removeZero(int[] oldArray){
+ if (oldArray == null || oldArray.length == 0){
+ return oldArray;
+ }
+ int count = 0;
+ for (int i = 0; i < oldArray.length; i++) {
+ if (oldArray[i] != 0) {
+ count++;
+ }
+ }
+ int[] newArray = new int[count];
+ int j = 0;
+ for (int i = 0; i <= oldArray.length - 1; i++) {
+ if (oldArray[i] == 0) {
+ continue;
+ }
+ newArray[j++] = oldArray[i];
+ }
+ return newArray;
+ }
+
+ /**
+ * 缁欏畾涓や釜宸茬粡鎺掑簭濂界殑鏁村舰鏁扮粍锛 a1鍜宎2 , 鍒涘缓涓涓柊鐨勬暟缁刟3, 浣垮緱a3 鍖呭惈a1鍜宎2 鐨勬墍鏈夊厓绱狅紝 骞朵笖浠嶇劧鏄湁搴忕殑
+ * 渚嬪 a1 = [3, 5, 7,8] a2 = [4, 5, 6,7] 鍒 a3 涓篬3,4,5,6,7,8] , 娉ㄦ剰锛 宸茬粡娑堥櫎浜嗛噸澶
+ * @param array1
+ * @param array2
+ * @return
+ */
+
+ public int[] merge(int[] array1, int[] array2){
+ if (array1 == null && array2 == null) {
+ return null;
+ }
+ if (array1 == null) {
+ return array2;
+ }
+ if (array2 == null) {
+ return array1;
+ }
+ int i=0, j=0, k=0;
+ int len1 = array1.length;
+ int len2 = array2.length;
+ int[] mergeArr = new int[len1+len2];
+ while(true){
+ if(i == len1 || j == len2)
+ break;
+ if(array1[i]array2[j]){
+ mergeArr[k++] = array2[j++];
+ }else{
+ mergeArr[k++] = array1[i++];
+ j++;
+ }
+ }
+
+ for(;i list = new ArrayList<>();
+ int f1 = 1, f2 = 1, f3;
+ list.add(f1);
+ list.add(f2);
+ while (f1 +f2 < max) {
+ f3 = f1 + f2;
+ list.add(f3);
+ f1 = f2;
+ f2 = f3;
+ }
+ int[] result = new int[list.size()];
+ int j = 0;
+ for(Integer i : list) {
+ result[j++] = i;
+ }
+ return result;
+ }
+
+ /**
+ * 杩斿洖灏忎簬缁欏畾鏈澶у糾ax鐨勬墍鏈夌礌鏁版暟缁
+ * 渚嬪max = 23, 杩斿洖鐨勬暟缁勪负[2,3,5,7,11,13,17,19]
+ * @param max
+ * @return
+ */
+ public int[] getPrimes(int max){
+ int[] a = new int[max];
+ int k=0;
+ for (int z = 1; ztype){
+ try {
+ Method met = obj.getClass().getMethod("set" + initStr(att), type);
+ met.invoke(obj, value);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ private static String getter(Object obj, String att){
+ try {
+ Method met = obj.getClass().getMethod("get" + initStr(att));
+ return (String)met.invoke(obj);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ return null;
+ }
+ private static String initStr(String name) {
+ name = name.substring(0, 1).toUpperCase() + name.substring(1);
+ return name;
+ }
+
+ private static String toLowerString(String name) {
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
+ return name;
+ }
+
+
+ public static View runAction(String actionName, Map parameters) {
+
+ /*
+
+ 0. 璇诲彇閰嶇疆鏂囦欢struts.xml
+
+ 1. 鏍规嵁actionName鎵惧埌鐩稿搴旂殑class 锛 渚嬪LoginAction, 閫氳繃鍙嶅皠瀹炰緥鍖栵紙鍒涘缓瀵硅薄锛
+ 鎹畃arameters涓殑鏁版嵁锛岃皟鐢ㄥ璞$殑setter鏂规硶锛 渚嬪parameters涓殑鏁版嵁鏄
+ ("name"="test" , "password"="1234") ,
+ 閭e氨搴旇璋冪敤 setName鍜宻etPassword鏂规硶
+
+ 2. 閫氳繃鍙嶅皠璋冪敤瀵硅薄鐨別xectue 鏂规硶锛 骞惰幏寰楄繑鍥炲硷紝渚嬪"success"
+
+ 3. 閫氳繃鍙嶅皠鎵惧埌瀵硅薄鐨勬墍鏈塯etter鏂规硶锛堜緥濡 getMessage锛,
+ 閫氳繃鍙嶅皠鏉ヨ皟鐢紝 鎶婂煎拰灞炴у舰鎴愪竴涓狧ashMap , 渚嬪 {"message": "鐧诲綍鎴愬姛"} ,
+ 鏀惧埌View瀵硅薄鐨刾arameters
+
+ 4. 鏍规嵁struts.xml涓殑 閰嶇疆,浠ュ強execute鐨勮繑鍥炲硷紝 纭畾鍝竴涓猨sp锛
+ 鏀惧埌View瀵硅薄鐨刯sp瀛楁涓
+
+ */
+ SAXReader saxReader = new SAXReader();
+ try {
+ Document document = saxReader.read(new File("struts.xml"));
+ Element root = document.getRootElement();
+
+
+ boolean flag = false;
+ String className = "";
+ Element action = null;
+ for (Iterator iter = root.elementIterator(); iter.hasNext();)
+ {
+ Element e = (Element) iter.next();
+ if(e.attributeValue("name").equals(actionName)){
+ flag = true;
+ className = e.attributeValue("class");
+ action = e;
+ break;
+ }
+ }
+ if(!flag)
+ throw new Exception(actionName+"鏈畾涔");
+
+ Class> clz = Class.forName(className);
+ Constructor> c = clz.getConstructor();
+ Object obj = c.newInstance();
+
+ for (String in : parameters.keySet()) {
+ setter(obj,in,parameters.get(in), String.class);
+ }
+ Method exc = clz.getDeclaredMethod("execute");
+ String res = (String)exc.invoke(obj);
+
+ //鑾峰彇鎵鏈塯etter鏂规硶
+ //Get the methods
+ Method[] methods = clz.getDeclaredMethods();
+ //Loop through the methods and print out their names
+ Map params = new HashMap();
+
+ for (Method method : methods) {
+ String name = method.getName();
+ if(name.substring(0,3).equals("get")){
+ params.put(toLowerString(name.substring(3)),getter(obj,toLowerString(name.substring(3))));
+ }
+ }
+ View view = new View();
+ view.setParameters(params);
+ //step 4
+ flag = false;
+ Element result = null;
+ List actionChildList = action.elements("result");
+ for (Iterator iter = action.elementIterator(); iter.hasNext();){
+ Element e = (Element) iter.next();
+ if(e.attributeValue("name").equals(res)){
+ flag = true;
+ result = e;
+ break;
+ }
+ }
+ if(!flag)
+ throw new Exception(res+"undefined");
+ view.setJsp(result.getText());
+ return view;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
diff --git a/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/StrutsTest.java b/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/StrutsTest.java
new file mode 100644
index 0000000000..c5ee5f10a9
--- /dev/null
+++ b/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/StrutsTest.java
@@ -0,0 +1,43 @@
+package com.github.fei9009.coderising0226.litestruts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+
+public class StrutsTest {
+
+ @Test
+ public void testLoginActionSuccess() {
+
+ String actionName = "login";
+
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","1234");
+
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/homepage.jsp", view.getJsp());
+ Assert.assertEquals("login successful", view.getParameters().get("message"));
+ }
+
+ @Test
+ public void testLoginActionFailed() {
+ String actionName = "login";
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","123456"); //瀵嗙爜鍜岄璁剧殑涓嶄竴鑷
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp());
+ Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message"));
+ }
+}
diff --git a/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/View.java b/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/View.java
new file mode 100644
index 0000000000..9332493c42
--- /dev/null
+++ b/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/View.java
@@ -0,0 +1,23 @@
+package com.github.fei9009.coderising0226.litestruts;
+
+import java.util.Map;
+
+public class View {
+ private String jsp;
+ private Map parameters;
+
+ public String getJsp() {
+ return jsp;
+ }
+ public View setJsp(String jsp) {
+ this.jsp = jsp;
+ return this;
+ }
+ public Map getParameters() {
+ return parameters;
+ }
+ public View setParameters(Map parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+}
diff --git a/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/struts.xml b/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/struts.xml
new file mode 100644
index 0000000000..68098b57e3
--- /dev/null
+++ b/group02/527705641/src/com/github/fei9009/coderising0226/litestruts/struts.xml
@@ -0,0 +1,11 @@
+
+
+
+ /jsp/homepage.jsp
+ /jsp/showLogin.jsp
+
+
+ /jsp/welcome.jsp
+ /jsp/error.jsp
+
+
\ No newline at end of file
diff --git a/group02/562768642/bin/com/github/orajavac/coding2017/litestructs/struts.xml b/group02/562768642/bin/com/github/orajavac/coding2017/litestructs/struts.xml
new file mode 100644
index 0000000000..6e5022fb64
--- /dev/null
+++ b/group02/562768642/bin/com/github/orajavac/coding2017/litestructs/struts.xml
@@ -0,0 +1,11 @@
+
+
+
+ /jsp/homepage.jsp
+ /jsp/showLogin.jsp
+
+
+ /jsp/welcome.jsp
+ /jsp/error.jsp
+
+
\ No newline at end of file
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/array/ArrayUtil.java b/group02/562768642/src/com/github/orajavac/coding2017/array/ArrayUtil.java
new file mode 100644
index 0000000000..62de048a68
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/array/ArrayUtil.java
@@ -0,0 +1,234 @@
+package com.github.orajavac.coding2017.array;
+
+public class ArrayUtil {
+
+ /**
+ * 缁欏畾涓涓暣褰㈡暟缁刟 , 瀵硅鏁扮粍鐨勫艰繘琛岀疆鎹
+ 渚嬪锛 a = [7, 9 , 30, 3] , 缃崲鍚庝负 [3, 30, 9,7]
+ 濡傛灉 a = [7, 9, 30, 3, 4] , 缃崲鍚庝负 [4,3, 30 , 9,7]
+ * @param origin
+ * @return
+ */
+ public void reverseArray(int[] origin){
+ int temp;
+ int c=origin.length;
+ for (int i=0,j=origin.length-1;itarget[j+1]){
+ t=target[j];
+ target[j]=target[j+1];
+ target[j+1]=t;
+ }
+ }
+ return removeZero(target);
+ }
+
+ /**
+ * 鎶婁竴涓凡缁忓瓨婊℃暟鎹殑鏁扮粍 oldArray鐨勫閲忚繘琛屾墿灞曪紝 鎵╁睍鍚庣殑鏂版暟鎹ぇ灏忎负oldArray.length + size
+ * 娉ㄦ剰锛岃佹暟缁勭殑鍏冪礌鍦ㄦ柊鏁扮粍涓渶瑕佷繚鎸
+ * 渚嬪 oldArray = [2,3,6] , size = 3,鍒欒繑鍥炵殑鏂版暟缁勪负
+ * [2,3,6,0,0,0]
+ * @param oldArray
+ * @param size
+ * @return
+ */
+ public int[] grow(int [] oldArray, int size){
+ int[] target = new int[size];
+ for (int i=0;iindex){
if(i+1!=len){
elementData[i]=elementData[i+1];
- }else{ //我们假设数组索引 0-3,那么数组长度是4,3+1==4,elementData[i+1]会报错
+ }else{ //鎴戜滑鍋囪鏁扮粍绱㈠紩 0-3锛岄偅涔堟暟缁勯暱搴︽槸4锛3+1==4锛宔lementData[i+1]浼氭姤閿
elementData[i]=null;
}
}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/litestructs/LoginAction.java b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/LoginAction.java
new file mode 100644
index 0000000000..7c16390ef1
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/LoginAction.java
@@ -0,0 +1,43 @@
+package com.github.orajavac.coding2017.litestructs;
+
+/**
+ * 杩欐槸涓涓敤鏉ュ睍绀虹櫥褰曠殑涓氬姟绫伙紝 鍏朵腑鐨勭敤鎴峰悕鍜屽瘑鐮侀兘鏄‖缂栫爜鐨勩
+ * @author liuxin
+ *
+ */
+public class LoginAction{
+ private String name ;
+ private String password;
+ private String message;
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String execute(){
+ if("test".equals(name) && "1234".equals(password)){
+ this.message = "login successful";
+ return "success";
+ }
+ this.message = "login failed,please check your user/pwd";
+ return "fail";
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+ public void setPassword(String password){
+ this.password = password;
+ }
+ public String getMessage(){
+ return this.message;
+ }
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/litestructs/Struts.java b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/Struts.java
new file mode 100644
index 0000000000..a5ea0cd702
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/Struts.java
@@ -0,0 +1,99 @@
+package com.github.orajavac.coding2017.litestructs;
+
+import java.beans.PropertyDescriptor;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+import java.util.Iterator;
+
+import org.dom4j.Attribute;
+import org.dom4j.Element;
+import org.dom4j.Document;
+import org.dom4j.io.SAXReader;
+
+
+public class Struts {
+
+ private static Map xmlMap = new HashMap();
+
+ public static View runAction(String actionName, Map parameters) {
+ /*
+
+ 0. 璇诲彇閰嶇疆鏂囦欢struts.xml
+
+ 1. 鏍规嵁actionName鎵惧埌鐩稿搴旂殑class 锛 渚嬪LoginAction, 閫氳繃鍙嶅皠瀹炰緥鍖栵紙鍒涘缓瀵硅薄锛
+ 鎹畃arameters涓殑鏁版嵁锛岃皟鐢ㄥ璞$殑setter鏂规硶锛 渚嬪parameters涓殑鏁版嵁鏄
+ ("name"="test" , "password"="1234") ,
+ 閭e氨搴旇璋冪敤 setName鍜宻etPassword鏂规硶
+
+ 2. 閫氳繃鍙嶅皠璋冪敤瀵硅薄鐨別xectue 鏂规硶锛 骞惰幏寰楄繑鍥炲硷紝渚嬪"success"
+
+ 3. 閫氳繃鍙嶅皠鎵惧埌瀵硅薄鐨勬墍鏈塯etter鏂规硶锛堜緥濡 getMessage锛,
+ 閫氳繃鍙嶅皠鏉ヨ皟鐢紝 鎶婂煎拰灞炴у舰鎴愪竴涓狧ashMap , 渚嬪 {"message": "鐧诲綍鎴愬姛"} ,
+ 鏀惧埌View瀵硅薄鐨刾arameters
+
+ 4. 鏍规嵁struts.xml涓殑 閰嶇疆,浠ュ強execute鐨勮繑鍥炲硷紝 纭畾鍝竴涓猨sp锛
+ 鏀惧埌View瀵硅薄鐨刯sp瀛楁涓
+ */
+ try{
+ if(xmlMap.size()==0)
+ Struts.DOM4jParserXml();
+
+ StrutsXml sx = xmlMap.get(actionName);
+ Class> clz = Class.forName(sx.getClassz());
+ Object o = clz.newInstance();
+ String key = null;
+ Method[] mets = clz.getDeclaredMethods();
+ for (Method m : mets){
+ if(m.getName().startsWith("set")){
+ key = m.getName().substring(3,m.getName().length()).toLowerCase();
+ m.invoke(o,parameters.get(key));
+ }
+ }
+ Method m1 = clz.getDeclaredMethod("execute");
+ String result = (String)m1.invoke(o);
+ Map param = new HashMap();
+ Field[] fields = clz.getDeclaredFields();
+ for(int i=0;i iterator = root.elementIterator();
+ while(iterator.hasNext()){
+ Element e = iterator.next();
+ StrutsXml sx = new StrutsXml();
+ sx.setName(e.attribute("name").getValue());
+ sx.setClassz(e.attribute("class").getValue());
+ xmlMap.put(e.attribute("name").getValue(), sx);
+ Iterator r = e.elementIterator("result");
+ while(r.hasNext()){
+ Element child = r.next();
+ sx.getResult().put(child.attribute("name").getValue(), child.getTextTrim());
+ }
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/litestructs/StrutsTest.java b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/StrutsTest.java
new file mode 100644
index 0000000000..447dc3a24b
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/StrutsTest.java
@@ -0,0 +1,43 @@
+package com.github.orajavac.coding2017.litestructs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+
+
+public class StrutsTest {
+
+ @Test
+ public void testLoginActionSuccess() {
+
+ String actionName = "login";
+
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","1234");
+
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/homepage.jsp", view.getJsp());
+ Assert.assertEquals("login successful", view.getParameters().get("message"));
+ }
+
+ @Test
+ public void testLoginActionFailed() {
+ String actionName = "login";
+ Map params = new HashMap();
+ params.put("name","test");
+ params.put("password","123456"); //瀵嗙爜鍜岄璁剧殑涓嶄竴鑷
+
+ View view = Struts.runAction(actionName,params);
+
+ Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp());
+ Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message"));
+ }
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/litestructs/StrutsXml.java b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/StrutsXml.java
new file mode 100644
index 0000000000..b22eb3ba05
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/StrutsXml.java
@@ -0,0 +1,28 @@
+package com.github.orajavac.coding2017.litestructs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class StrutsXml {
+ private String name;
+ private String classz;
+ private Map result = new HashMap();
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getClassz() {
+ return classz;
+ }
+ public void setClassz(String classz) {
+ this.classz = classz;
+ }
+ public Map getResult() {
+ return result;
+ }
+ public void setResult(Map result) {
+ this.result = result;
+ }
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/litestructs/View.java b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/View.java
new file mode 100644
index 0000000000..49c5feeba3
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/View.java
@@ -0,0 +1,23 @@
+package com.github.orajavac.coding2017.litestructs;
+
+import java.util.Map;
+
+public class View {
+ private String jsp;
+ private Map parameters;
+
+ public String getJsp() {
+ return jsp;
+ }
+ public View setJsp(String jsp) {
+ this.jsp = jsp;
+ return this;
+ }
+ public Map getParameters() {
+ return parameters;
+ }
+ public View setParameters(Map parameters) {
+ this.parameters = parameters;
+ return this;
+ }
+}
diff --git a/group02/562768642/src/com/github/orajavac/coding2017/litestructs/struts.xml b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/struts.xml
new file mode 100644
index 0000000000..6e5022fb64
--- /dev/null
+++ b/group02/562768642/src/com/github/orajavac/coding2017/litestructs/struts.xml
@@ -0,0 +1,11 @@
+
+
+
+ /jsp/homepage.jsp
+ /jsp/showLogin.jsp
+
+
+ /jsp/welcome.jsp
+ /jsp/error.jsp
+
+
\ No newline at end of file
diff --git a/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/ArrayUtil.java b/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/ArrayUtil.java
new file mode 100644
index 0000000000..2e9c09effc
--- /dev/null
+++ b/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/ArrayUtil.java
@@ -0,0 +1,294 @@
+package com.github.congcongcong250.coding2017.basic;
+
+import java.util.Arrays;
+import java.util.ArrayList;
+
+public class ArrayUtil {
+
+ /**
+ * 缁欏畾涓涓暣褰㈡暟缁刟 , 瀵硅鏁扮粍鐨勫艰繘琛岀疆鎹 渚嬪锛 a = [7, 9 , 30, 3] , 缃崲鍚庝负 [3, 30, 9,7] 濡傛灉 a =
+ * [7, 9, 30, 3, 4] , 缃崲鍚庝负 [4,3, 30 , 9,7]
+ *
+ * @param origin
+ * @return
+ */
+ public void reverseArray(int[] origin) {
+
+ int[] copy = origin.clone();
+ int j, last = copy.length - 1;
+
+ for (int i = last; i >= 0; i--) {
+ j = last - i;
+ origin[i] = copy[j];
+ }
+
+ }
+
+ /**
+ * 鐜板湪鏈夊涓嬬殑涓涓暟缁勶細 int oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5}
+ * 瑕佹眰灏嗕互涓婃暟缁勪腑鍊间负0鐨勯」鍘绘帀锛屽皢涓嶄负0鐨勫煎瓨鍏ヤ竴涓柊鐨勬暟缁勶紝鐢熸垚鐨勬柊鏁扮粍涓猴細 {1,3,4,5,6,6,5,4,7,6,7,5}
+ *
+ * @param oldArray
+ * @return
+ */
+
+ public int[] removeZero(int[] oldArray) {
+ /*
+ * Method 1, traverse oldArray and count non-zero value, create new
+ * int[count], traverse again oldArray and insert to new one
+ */
+
+ /*
+ * Method 2, traverse olArray and insert non-zero value to an List,
+ * then List.toArray().
+ */
+
+ // Method 3
+ if(oldArray == null){
+ return null;
+ }
+ int[] tmp = new int[oldArray.length];
+ int count = 0;
+
+ for (int v : oldArray) {
+ if (v != 0) {
+ tmp[count] = v;
+ count++;
+ }
+ }
+
+ return Arrays.copyOf(tmp, count);
+ }
+
+ /**
+ * 缁欏畾涓や釜宸茬粡鎺掑簭濂界殑鏁村舰鏁扮粍锛 a1鍜宎2 , 鍒涘缓涓涓柊鐨勬暟缁刟3, 浣垮緱a3 鍖呭惈a1鍜宎2 鐨勬墍鏈夊厓绱狅紝 骞朵笖浠嶇劧鏄湁搴忕殑 渚嬪 a1 =
+ * [3, 5, 7,8] a2 = [4, 5, 6,7] 鍒 a3 涓篬3,4,5,6,7,8] , 娉ㄦ剰锛 宸茬粡娑堥櫎浜嗛噸澶
+ *
+ * @param array1
+ * @param array2
+ * @return
+ */
+
+ public int[] merge(int[] array1, int[] array2) {
+ if (array1 == null) {
+ if (array2 == null) {
+ return null;
+ }
+ return array2;
+ } else if (array2 == null) {
+ return array1;
+ }
+
+ int l1 = array1.length, l2 = array2.length;
+ int[] whole = new int[l1 + l2];
+
+ int dupValue = 0;
+ int dupCount = 0;
+ boolean isDup = false;
+
+ int j = 0;
+ // Traverse array1
+ for (int i = 0; i < l1; i++) {
+
+ // Get rid of duplicate value in array1
+ if (isDup) {
+ if (array1[i] == dupValue) {
+ dupCount++;
+ continue;
+ } else {
+ isDup = false;
+ }
+ }
+
+ while (j < l2) {
+ if (array1[i] > array2[j]) {
+ // If int from array1 is larger, add int from array2 first
+ whole[i + j - dupCount] = array2[j];
+ j++;
+ continue;
+ } else if (array1[i] == array2[j]) {
+ // If equals, skip int from array2, and set duplicate value
+ isDup = true;
+ dupValue = array1[i];
+ dupCount++;
+ j++;
+ continue;
+ } else if (array1[i] < array2[j]) {
+ // If smaller, break and add from in array1
+ break;
+ }
+ }
+ whole[i + j - dupCount] = array1[i];
+ }
+
+ // Deal with left over in array2
+ while (j < l2) {
+ whole[l1 + j - dupCount] = array2[j];
+ j++;
+ }
+
+ return Arrays.copyOf(whole, l1 + l2 - dupCount);
+ }
+
+ /**
+ * 鎶婁竴涓凡缁忓瓨婊℃暟鎹殑鏁扮粍 oldArray鐨勫閲忚繘琛屾墿灞曪紝 鎵╁睍鍚庣殑鏂版暟鎹ぇ灏忎负oldArray.length + size
+ * 娉ㄦ剰锛岃佹暟缁勭殑鍏冪礌鍦ㄦ柊鏁扮粍涓渶瑕佷繚鎸 渚嬪 oldArray = [2,3,6] , size = 3,鍒欒繑鍥炵殑鏂版暟缁勪负
+ * [2,3,6,0,0,0]
+ *
+ * @param oldArray
+ * @param size
+ * @return
+ */
+ public int[] grow(int[] oldArray, int size) {
+ checkGrowSize(size);
+ if (oldArray == null) {
+ return null;
+ }
+ int newlength = oldArray.length + size;
+ int[] res = new int[newlength];
+ res = Arrays.copyOf(oldArray, newlength);
+
+ return res;
+ }
+
+ private void checkGrowSize(int size) {
+ if (size < 0) {
+ throw new IndexOutOfBoundsException(
+ "Negative size is not allowed in grow()");
+ }
+ }
+
+ /**
+ * 鏂愭尝閭e鏁板垪涓猴細1锛1锛2锛3锛5锛8锛13锛21...... 锛岀粰瀹氫竴涓渶澶у硷紝 杩斿洖灏忎簬璇ュ肩殑鏁板垪 渚嬪锛 max = 15 ,
+ * 鍒欒繑鍥炵殑鏁扮粍搴旇涓 [1锛1锛2锛3锛5锛8锛13] max = 1, 鍒欒繑鍥炵┖鏁扮粍 []
+ *
+ * @param max
+ * @return
+ */
+ public int[] fibonacci(int max) {
+ if (max <= 1) {
+ return new int[0];
+ }
+
+ // Fib(47) == 2971215073 > INT_MAX;
+ int[] tmp = new int[46];
+ tmp[0] = 1;
+ tmp[1] = 1;
+
+ int next = 1 + 1;
+ int i = 1;
+ while (next < max) {
+ i++;
+ tmp[i] = next;
+ next = tmp[i] + tmp[i - 1];
+ }
+
+ return Arrays.copyOf(tmp, i + 1);
+ }
+
+ /**
+ * 杩斿洖灏忎簬缁欏畾鏈澶у糾ax鐨勬墍鏈夌礌鏁版暟缁 渚嬪max = 23, 杩斿洖鐨勬暟缁勪负[2,3,5,7,11,13,17,19]
+ *
+ * @param max
+ * @return
+ */
+ public int[] getPrimes(int max) {
+ if (max <= 2) {
+ return new int[0];
+ }
+
+ ArrayList primeList = new ArrayList();
+ primeList.add(2);
+
+ for (int candidate = 3; candidate < max; candidate += 2) {
+ // For every number smaller than max
+ int ceiling = (int) Math.floor(Math.sqrt(candidate));
+ for (Integer prime : primeList) {
+ // Divided by every prime number smaller than sqrt(candidate)
+ if (candidate % prime == 0) {
+ // When reminder equals 0, candidate is not a prime
+ break;
+ }
+ if (prime > ceiling) {
+ // When every prime number <= sqrt(candidate), add candidate to primelist
+ primeList.add(candidate);
+ break;
+ }
+ }
+ }
+
+ // Transfer primelist to int array
+ int[] res = arrayFromList(primeList);
+
+ return res;
+ }
+
+ /**
+ * 鎵璋撯滃畬鏁扳濓紝 鏄寚杩欎釜鏁版伆濂界瓑浜庡畠鐨勫洜瀛愪箣鍜岋紝渚嬪6=1+2+3 缁欏畾涓涓渶澶у糾ax锛 杩斿洖涓涓暟缁勶紝 鏁扮粍涓槸灏忎簬max 鐨勬墍鏈夊畬鏁
+ *
+ * @param max
+ * @return
+ */
+ public int[] getPerfectNumbers(int max) {
+ if (max <= 2) {
+ return new int[0];
+ }
+
+ ArrayList perfectList = new ArrayList();
+
+ for (int candidate = 2; candidate < max; candidate++) {
+ int sum = 1;
+ int ceiling = (int) Math.floor(Math.sqrt(candidate));
+ if (Math.sqrt(candidate) == ceiling) {
+ sum += ceiling;
+ }
+ // For each number smaller than max
+ for (int divisor = 2; divisor <= ceiling; divisor++) {
+ if (candidate % divisor == 0) {
+ sum += divisor;
+ sum += candidate / divisor;
+ }
+ if (sum > candidate) {
+ break;
+ }
+ }
+ if (sum == candidate) {
+ perfectList.add(candidate);
+ }
+ }
+
+ // Transfer primelist to int array
+ int[] res = arrayFromList(perfectList);
+
+ return res;
+ }
+
+ private int[] arrayFromList(ArrayList list) {
+ int[] r = new int[list.size()];
+ int j = 0;
+ for (Integer v : list) {
+ r[j++] = v;
+ }
+ return r;
+ }
+
+ /**
+ * 鐢╯eperator 鎶婃暟缁 array缁欒繛鎺ヨ捣鏉 渚嬪array= [3,8,9], seperator = "-" 鍒欒繑鍥炲间负"3-8-9"
+ *
+ * @param array
+ * @param s
+ * @return
+ */
+ public String join(int[] array, String seperator) {
+ String res = "";
+ if (array == null || array.length == 0) {
+ return res;
+ }
+ res += array[0];
+ for (int i = 1; i < array.length; i++) {
+ res += seperator + array[i];
+ }
+ return res;
+ }
+
+}
diff --git a/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/ArrayList.java b/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/WArrayList.java
similarity index 87%
rename from group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/ArrayList.java
rename to group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/WArrayList.java
index af4588763e..4aa718017a 100644
--- a/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/ArrayList.java
+++ b/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/WArrayList.java
@@ -4,7 +4,7 @@
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
-public class ArrayList implements List {
+public class WArrayList implements WList {
private int size = 0;
@@ -63,7 +63,7 @@ public int size(){
return size;
}
- public Iterator iterator(){
+ public WIterator wIterator(){
return new Itr();
}
@@ -79,7 +79,7 @@ private void checkIndex(int index){
}
- private class Itr implements Iterator{
+ private class Itr implements WIterator{
//index for next element to visit
private int cursor = 0;
@@ -103,7 +103,7 @@ public void remove() {
throw new NoSuchElementException();
}
- ArrayList.this.remove(--cursor);
+ WArrayList.this.remove(--cursor);
}
}
diff --git a/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/BinaryTreeNode.java b/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/WBinaryTreeNode.java
similarity index 59%
rename from group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/BinaryTreeNode.java
rename to group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/WBinaryTreeNode.java
index 9e0e5aa10e..6601a5cd0a 100644
--- a/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/BinaryTreeNode.java
+++ b/group02/609990377/DataStructure/src/com/github/congcongcong250/coding2017/basic/WBinaryTreeNode.java
@@ -1,18 +1,18 @@
package com.github.congcongcong250.coding2017.basic;
-public class BinaryTreeNode