From 35d23c6e8b2a287c70ad53f13ba14f836761623f Mon Sep 17 00:00:00 2001
From: liyuewei <2847524632@qq.com>
Date: Thu, 24 Nov 2016 00:01:39 +0800
Subject: [PATCH 1/6] InsertionSort demo
---
src/com/lyw/demo/InsertionSort.java | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 src/com/lyw/demo/InsertionSort.java
diff --git a/src/com/lyw/demo/InsertionSort.java b/src/com/lyw/demo/InsertionSort.java
new file mode 100644
index 0000000..33ce0e5
--- /dev/null
+++ b/src/com/lyw/demo/InsertionSort.java
@@ -0,0 +1,8 @@
+package com.lyw.demo;
+
+/**
+ * Created by Administrator on 2016/11/24 0024.
+ * 插入排序
+ */
+public class InsertionSort {
+}
From 6be88345f0176153f8c3049a37c05206960f23ae Mon Sep 17 00:00:00 2001
From: liyuewei <2847524632@qq.com>
Date: Thu, 24 Nov 2016 09:01:34 +0800
Subject: [PATCH 2/6] InsertionSort demo
---
src/com/lyw/demo/InsertionSort.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/com/lyw/demo/InsertionSort.java b/src/com/lyw/demo/InsertionSort.java
index 33ce0e5..2a7e770 100644
--- a/src/com/lyw/demo/InsertionSort.java
+++ b/src/com/lyw/demo/InsertionSort.java
@@ -5,4 +5,23 @@
* 插入排序
*/
public class InsertionSort {
+ public static void main(String[] args) {
+ int[] array = {1, -5, 3, 78, 5, 10};
+ insertionSort(array);
+ for (int i : array) {
+ System.out.println(i);
+ }
+ }
+
+ private static void insertionSort(int[] arr) {
+ for (int i = 1; i < arr.length; i++) {
+ int key = arr[i];
+ int j = i - 1;
+ while (j >= 0 && arr[j] > key) {
+ arr[j + 1] = arr[j];
+ j--;
+ }
+ arr[j + 1] = key;
+ }
+ }
}
From fb674988fa3d5819bafc61ca9e930c7f098fdf22 Mon Sep 17 00:00:00 2001
From: liyuewei <2847524632@qq.com>
Date: Thu, 24 Nov 2016 09:35:03 +0800
Subject: [PATCH 3/6] InsertionSort demo
---
.idea/vcs.xml | 6 ++++++
src/com/lyw/demo/InsertionSort.java | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
create mode 100644 .idea/vcs.xml
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/lyw/demo/InsertionSort.java b/src/com/lyw/demo/InsertionSort.java
index 2a7e770..11bf480 100644
--- a/src/com/lyw/demo/InsertionSort.java
+++ b/src/com/lyw/demo/InsertionSort.java
@@ -6,10 +6,10 @@
*/
public class InsertionSort {
public static void main(String[] args) {
- int[] array = {1, -5, 3, 78, 5, 10};
+ int[] array = {1, -5, 3, 78, 5, 0};
insertionSort(array);
for (int i : array) {
- System.out.println(i);
+ System.out.print(i + "\t");
}
}
From d1363f8ecb8035ec21dae7ad6468e99242575c65 Mon Sep 17 00:00:00 2001
From: liyuewei <2847524632@qq.com>
Date: Sat, 26 Nov 2016 15:12:04 +0800
Subject: [PATCH 4/6] InsertionSort demo
---
.idea/codeStyleSettings.xml | 13 +++++++++++++
.idea/misc.xml | 7 -------
src/com/lyw/demo/Demo1.java | 28 ++++++++++++++++++++++++++++
src/com/lyw/demo/Demo2.java | 22 ++++++++++++++++++++++
src/com/lyw/demo/HelloWorld.java | 2 ++
5 files changed, 65 insertions(+), 7 deletions(-)
create mode 100644 .idea/codeStyleSettings.xml
create mode 100644 src/com/lyw/demo/Demo1.java
create mode 100644 src/com/lyw/demo/Demo2.java
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
new file mode 100644
index 0000000..7fb8ed0
--- /dev/null
+++ b/.idea/codeStyleSettings.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e1f0da4..a9c9ebd 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -41,13 +41,6 @@
-
-
-
-
-
-
-
diff --git a/src/com/lyw/demo/Demo1.java b/src/com/lyw/demo/Demo1.java
new file mode 100644
index 0000000..c5c6d2a
--- /dev/null
+++ b/src/com/lyw/demo/Demo1.java
@@ -0,0 +1,28 @@
+package com.lyw.demo;
+
+/**
+ * 快捷模板练习
+ *
+ * @author Administrator
+ * @create 2016-11-26-上午 9:00
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class Demo1 {
+
+ public static void main(String[] args) {
+ int temp1 = 100;
+ int temp2 = 50;
+ int temp3 = addNum(temp1, temp2);
+ //
+ System.out.println("------------YouMeek.com-----------temp3值=" + temp3 + "," + "当前类=Demo1.main()");
+ System.out.println("------------YouMeek.com-----------temp2值=" + temp2 + "," + "当前类=Demo1.main()");
+ System.out.println("------------YouMeek.com-----------temp1值=" + temp1 + "," + "当前类=Demo1.main()");
+ //
+
+ }
+
+ private static int addNum(int param1, int param2) {
+ int param3 = param1 + param2;
+ return param3;
+ }
+}
diff --git a/src/com/lyw/demo/Demo2.java b/src/com/lyw/demo/Demo2.java
new file mode 100644
index 0000000..4968f73
--- /dev/null
+++ b/src/com/lyw/demo/Demo2.java
@@ -0,0 +1,22 @@
+package com.lyw.demo;
+
+/**
+ * 重构测试类
+ *
+ * @author Administrator
+ * @create 2016-11-26-上午 10:51
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class Demo2 {
+
+
+ private static int num;
+
+ public static void main(String[] args) {
+ show(num);
+ }
+
+ private static void show(int num) {
+ System.out.println("------------YouMeek.com-----------num值=" + num + "," + "当前类=Demo2.main()");
+ }
+}
diff --git a/src/com/lyw/demo/HelloWorld.java b/src/com/lyw/demo/HelloWorld.java
index 9391687..5f98473 100644
--- a/src/com/lyw/demo/HelloWorld.java
+++ b/src/com/lyw/demo/HelloWorld.java
@@ -6,5 +6,7 @@
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
+ int num = 100;
+ System.out.println("------------YouMeek.com-----------num值=" + num + "," + "当前类=HelloWorld.main()");
}
}
From a49c97a65582ad51d54605591b265eee59717c83 Mon Sep 17 00:00:00 2001
From: liyuewei <2847524632@qq.com>
Date: Wed, 30 Nov 2016 13:04:25 +0800
Subject: [PATCH 5/6] =?UTF-8?q?java=E5=9F=BA=E7=A1=80=E7=BB=83=E4=B9=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/com/lyw/demo/Demo1.java | 28 ------------
src/com/lyw/demo/Demo2.java | 22 ----------
src/com/lyw/demo/HelloWorld.java | 12 ------
src/com/lyw/jichuyufa/HelloWorld.java | 14 ++++++
src/com/lyw/jichuyufa/OldSum.java | 19 ++++++++
src/com/lyw/jichuyufa/TestFor.java | 20 +++++++++
src/com/lyw/jichuyufa/TestIf.java | 23 ++++++++++
src/com/lyw/jichuyufa/TestVar.java | 43 +++++++++++++++++++
src/com/lyw/jichuyufa/TestVar2.java | 20 +++++++++
.../lyw/{demo => suanfa}/InsertionSort.java | 2 +-
10 files changed, 140 insertions(+), 63 deletions(-)
delete mode 100644 src/com/lyw/demo/Demo1.java
delete mode 100644 src/com/lyw/demo/Demo2.java
delete mode 100644 src/com/lyw/demo/HelloWorld.java
create mode 100644 src/com/lyw/jichuyufa/HelloWorld.java
create mode 100644 src/com/lyw/jichuyufa/OldSum.java
create mode 100644 src/com/lyw/jichuyufa/TestFor.java
create mode 100644 src/com/lyw/jichuyufa/TestIf.java
create mode 100644 src/com/lyw/jichuyufa/TestVar.java
create mode 100644 src/com/lyw/jichuyufa/TestVar2.java
rename src/com/lyw/{demo => suanfa}/InsertionSort.java (96%)
diff --git a/src/com/lyw/demo/Demo1.java b/src/com/lyw/demo/Demo1.java
deleted file mode 100644
index c5c6d2a..0000000
--- a/src/com/lyw/demo/Demo1.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.lyw.demo;
-
-/**
- * 快捷模板练习
- *
- * @author Administrator
- * @create 2016-11-26-上午 9:00
- * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
- */
-public class Demo1 {
-
- public static void main(String[] args) {
- int temp1 = 100;
- int temp2 = 50;
- int temp3 = addNum(temp1, temp2);
- //
- System.out.println("------------YouMeek.com-----------temp3值=" + temp3 + "," + "当前类=Demo1.main()");
- System.out.println("------------YouMeek.com-----------temp2值=" + temp2 + "," + "当前类=Demo1.main()");
- System.out.println("------------YouMeek.com-----------temp1值=" + temp1 + "," + "当前类=Demo1.main()");
- //
-
- }
-
- private static int addNum(int param1, int param2) {
- int param3 = param1 + param2;
- return param3;
- }
-}
diff --git a/src/com/lyw/demo/Demo2.java b/src/com/lyw/demo/Demo2.java
deleted file mode 100644
index 4968f73..0000000
--- a/src/com/lyw/demo/Demo2.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.lyw.demo;
-
-/**
- * 重构测试类
- *
- * @author Administrator
- * @create 2016-11-26-上午 10:51
- * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
- */
-public class Demo2 {
-
-
- private static int num;
-
- public static void main(String[] args) {
- show(num);
- }
-
- private static void show(int num) {
- System.out.println("------------YouMeek.com-----------num值=" + num + "," + "当前类=Demo2.main()");
- }
-}
diff --git a/src/com/lyw/demo/HelloWorld.java b/src/com/lyw/demo/HelloWorld.java
deleted file mode 100644
index 5f98473..0000000
--- a/src/com/lyw/demo/HelloWorld.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.lyw.demo;
-
-/**
- * Created by Administrator on 2016/11/22 0022.
- */
-public class HelloWorld {
- public static void main(String[] args) {
- System.out.println("Hello World!");
- int num = 100;
- System.out.println("------------YouMeek.com-----------num值=" + num + "," + "当前类=HelloWorld.main()");
- }
-}
diff --git a/src/com/lyw/jichuyufa/HelloWorld.java b/src/com/lyw/jichuyufa/HelloWorld.java
new file mode 100644
index 0000000..9fc4ea6
--- /dev/null
+++ b/src/com/lyw/jichuyufa/HelloWorld.java
@@ -0,0 +1,14 @@
+package com.lyw.jichuyufa;
+
+/**
+ * Java语言第一类
+ *
+ * @author Administrator
+ * @create 2016-11-30-上午 10:39
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class HelloWorld {
+ public static void main(String[] args) {
+ System.out.println("Hello,World");
+ }
+}
diff --git a/src/com/lyw/jichuyufa/OldSum.java b/src/com/lyw/jichuyufa/OldSum.java
new file mode 100644
index 0000000..2e6be61
--- /dev/null
+++ b/src/com/lyw/jichuyufa/OldSum.java
@@ -0,0 +1,19 @@
+package com.lyw.jichuyufa;
+
+/**
+ * 0~100之内奇数的和
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 12:58
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class OldSum {
+ public static void main(String[] args) {
+ int result = 0;
+ for (int i = 0; i < 100; i++) {
+ if (i % 2 != 0)
+ result += i;
+ }
+ System.out.println("0~100之内奇数的和为:" + result);
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestFor.java b/src/com/lyw/jichuyufa/TestFor.java
new file mode 100644
index 0000000..ea81f12
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestFor.java
@@ -0,0 +1,20 @@
+package com.lyw.jichuyufa;
+
+/**
+ * for循环
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 12:44
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestFor {
+ public static void main(String[] args) {
+ long result = 0;
+ long f = 1;
+ for (int i = 1; i <= 10; i++) {
+ f = f * i;
+ result += f;
+ }
+ System.out.println(result);
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestIf.java b/src/com/lyw/jichuyufa/TestIf.java
new file mode 100644
index 0000000..a76919c
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestIf.java
@@ -0,0 +1,23 @@
+package com.lyw.jichuyufa;
+
+/**
+ * 分支if
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 12:37
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestIf {
+ public static void main(String[] args) {
+ int i = 20;
+ if (i < 20) {
+ System.out.println("<20");
+ } else if (i < 40)
+ System.out.println("<40");
+ else if (i < 60)
+ System.out.println("<60");
+ else
+ System.out.println(">60");
+ System.out.println(">60");
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestVar.java b/src/com/lyw/jichuyufa/TestVar.java
new file mode 100644
index 0000000..88a6494
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestVar.java
@@ -0,0 +1,43 @@
+package com.lyw.jichuyufa;
+
+/**
+ * 变量作用域
+ *
+ * @author Administrator
+ * @create 2016-11-30-上午 10:41
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestVar {
+ static int j; //成员变量
+
+ public static void main(String[] args) {
+ int i = 0;
+ System.out.println(i);
+ System.out.println(j);
+
+ boolean b = false;
+ if (b) {
+ System.out.println("b is true");
+ }
+
+ long longNum1 = 8888888888888888888L;
+ }
+
+ public void m() {
+ int i = 0; //局部变量
+ int j = i + 5;
+ double d = 3.14;
+ Dog dog = new Dog(22, 7, 1964);
+ System.out.println(1);
+ }
+
+ private class Dog {
+ int day, month, year;
+
+ public Dog(int day, int month, int year) {
+ this.day = day;
+ this.month = month;
+ this.year = year;
+ }
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestVar2.java b/src/com/lyw/jichuyufa/TestVar2.java
new file mode 100644
index 0000000..4e95aac
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestVar2.java
@@ -0,0 +1,20 @@
+package com.lyw.jichuyufa;
+
+/**
+ * 数据类型练习
+ *
+ * @author Administrator
+ * @create 2016-11-30-上午 11:55
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestVar2 {
+ public static void main(String[] args) {
+ boolean b = true;
+ char x, y = 9;
+ x = 'a';
+ double num = 3.1415926;
+ System.out.println(String.format("b={0}", b));
+ System.out.println("x=" + x + ",y=" + y);
+ System.out.println("num=" + num);
+ }
+}
diff --git a/src/com/lyw/demo/InsertionSort.java b/src/com/lyw/suanfa/InsertionSort.java
similarity index 96%
rename from src/com/lyw/demo/InsertionSort.java
rename to src/com/lyw/suanfa/InsertionSort.java
index 11bf480..04c44e5 100644
--- a/src/com/lyw/demo/InsertionSort.java
+++ b/src/com/lyw/suanfa/InsertionSort.java
@@ -1,4 +1,4 @@
-package com.lyw.demo;
+package com.lyw.suanfa;
/**
* Created by Administrator on 2016/11/24 0024.
From 1421aaa0cee4c6ce0ad192a35fc84b2415d1d0aa Mon Sep 17 00:00:00 2001
From: liyuewei <2847524632@qq.com>
Date: Wed, 30 Nov 2016 14:02:59 +0800
Subject: [PATCH 6/6] =?UTF-8?q?java=E5=9F=BA=E7=A1=80=E7=BB=83=E4=B9=A0~?=
=?UTF-8?q?=E5=AE=8C=E5=B7=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/com/lyw/jichuyufa/OldSum.java | 10 ++++-
.../lyw/jichuyufa/TestBreakAndContinue.java | 25 ++++++++++++
src/com/lyw/jichuyufa/TestSwitch.java | 32 +++++++++++++++
.../lyw/jichuyufa/TestWhileAndDoWhile.java | 24 +++++++++++
src/com/lyw/jichuyufa/TestXunHuan.java | 40 +++++++++++++++++++
5 files changed, 130 insertions(+), 1 deletion(-)
create mode 100644 src/com/lyw/jichuyufa/TestBreakAndContinue.java
create mode 100644 src/com/lyw/jichuyufa/TestSwitch.java
create mode 100644 src/com/lyw/jichuyufa/TestWhileAndDoWhile.java
create mode 100644 src/com/lyw/jichuyufa/TestXunHuan.java
diff --git a/src/com/lyw/jichuyufa/OldSum.java b/src/com/lyw/jichuyufa/OldSum.java
index 2e6be61..75ef034 100644
--- a/src/com/lyw/jichuyufa/OldSum.java
+++ b/src/com/lyw/jichuyufa/OldSum.java
@@ -10,10 +10,18 @@
public class OldSum {
public static void main(String[] args) {
int result = 0;
- for (int i = 0; i < 100; i++) {
+
+ /*for (int i = 0; i < 100; i++) {
if (i % 2 != 0)
result += i;
+ }*/
+
+ for (int i = 1; i <= 99; i += 2) {
+ result += i;
}
+
System.out.println("0~100之内奇数的和为:" + result);
+
+
}
}
diff --git a/src/com/lyw/jichuyufa/TestBreakAndContinue.java b/src/com/lyw/jichuyufa/TestBreakAndContinue.java
new file mode 100644
index 0000000..d17ccea
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestBreakAndContinue.java
@@ -0,0 +1,25 @@
+package com.lyw.jichuyufa;
+
+/**
+ * break和continue
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 1:25
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestBreakAndContinue {
+ public static void main(String[] args) {
+ //break;
+ int stop = 4;
+ for (int i = 0; i < 10; i++) {
+ if (stop == i) break;
+ System.out.println(i);
+ }
+
+ //continue
+ for (int i = 0; i < 5; i++) {
+ if (stop == i) continue;
+ System.out.println(i);
+ }
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestSwitch.java b/src/com/lyw/jichuyufa/TestSwitch.java
new file mode 100644
index 0000000..94400f2
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestSwitch.java
@@ -0,0 +1,32 @@
+package com.lyw.jichuyufa;
+
+/**
+ * 分支Switch
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 1:45
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestSwitch {
+ public static void main(String[] args) {
+ int num = 2;
+ switch (num) {
+ case 1:
+ System.out.println("A");
+ break;
+ case 2:
+ System.out.println("B");
+ break;
+ case 3:
+ System.out.println("C");
+ break;
+ case 4:
+ case 5:
+ System.out.println("D");
+ break;
+ default:
+ System.out.println("error");
+ break;
+ }
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestWhileAndDoWhile.java b/src/com/lyw/jichuyufa/TestWhileAndDoWhile.java
new file mode 100644
index 0000000..91fe86b
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestWhileAndDoWhile.java
@@ -0,0 +1,24 @@
+package com.lyw.jichuyufa;
+
+/**
+ * while和do...while循环
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 1:10
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestWhileAndDoWhile {
+ public static void main(String[] args) {
+ int i = 0;
+ while ((i < 10)) {
+ System.out.println(i);
+ i++;
+ }
+
+ i = 0;
+ do {
+ System.out.println(i);
+ i++;
+ } while (i < 10);
+ }
+}
diff --git a/src/com/lyw/jichuyufa/TestXunHuan.java b/src/com/lyw/jichuyufa/TestXunHuan.java
new file mode 100644
index 0000000..ee5910c
--- /dev/null
+++ b/src/com/lyw/jichuyufa/TestXunHuan.java
@@ -0,0 +1,40 @@
+package com.lyw.jichuyufa;
+
+/**
+ * 循环测试
+ *
+ * @author Administrator
+ * @create 2016-11-30-下午 1:30
+ * 物勒工名,以考其诚,工有不当,必行其罪,以究其情
+ */
+public class TestXunHuan {
+ public static void main(String[] args) {
+ //输出1~100之内前5个可以被3整除的数字
+ int num = 0;
+ for (int i = 1; i <= 100; i++) {
+ if (i % 3 == 0) {
+ System.out.print(i + "\t");
+ num++;
+ }
+
+ if (num == 5) break;
+ }
+
+ System.out.println();
+
+ //输出101~200内的质数,质数只能被1和本身整除
+ for (int i = 101; i <= 200; i++) {
+ boolean flag = true;
+ for (int j = 2; j < i; j++) {
+ if (i % j == 0) {
+ flag = false;
+ break;
+ }
+ }
+ if (flag) {
+ System.out.print(i + "\t");
+ }
+ }
+
+ }
+}