Skip to content

Commit 6f81516

Browse files
author
robert
committed
modify digetst code
1 parent 819e5d1 commit 6f81516

File tree

14 files changed

+543
-683
lines changed

14 files changed

+543
-683
lines changed

.classpath

100755100644
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
5-
<classpathentry kind="output" path="bin"/>
6-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.project

100755100644
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<projectDescription>
3-
<name>algorithm</name>
4-
<comment></comment>
5-
<projects>
6-
</projects>
7-
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.jdt.core.javabuilder</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
13-
</buildSpec>
14-
<natures>
15-
<nature>org.eclipse.jdt.core.javanature</nature>
16-
</natures>
17-
</projectDescription>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>algorithm</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

100755100644
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
eclipse.preferences.version=1
2-
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4-
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5-
org.eclipse.jdt.core.compiler.compliance=1.7
6-
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7-
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8-
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9-
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10-
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11-
org.eclipse.jdt.core.compiler.source=1.7
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.7
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.7

src/com/algorithm/DeepSearch.java

100755100644
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package com.algorithm;
2-
3-
public class DeepSearch {
4-
5-
public static void main(String[] args) {
6-
int maze[][]=new int[10][10];
7-
8-
9-
}
10-
11-
}
1+
package com.algorithm;
2+
3+
public class DeepSearch {
4+
5+
public static void main(String[] args) {
6+
int maze[][]=new int[10][10];
7+
8+
9+
}
10+
11+
}

src/com/algorithm/JavaSort.java

100755100644
Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
package com.algorithm;
2-
3-
import java.io.BufferedReader;
4-
import java.io.IOException;
5-
import java.io.InputStreamReader;
6-
7-
public class JavaSort {
8-
9-
public static void main(String[] args) {
10-
int num[]=new int[100];
11-
String curnum;
12-
BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
13-
for(int i=0;i<10;i++)
14-
{
15-
try {
16-
curnum= read.readLine();
17-
num[i]=Integer.valueOf(curnum);
18-
System.out.print(num[i]+" ");
19-
} catch (IOException e) {
20-
e.printStackTrace();
21-
}
22-
}
23-
System.out.println();
24-
int temp;
25-
for(int i=1;i<10;i++)
26-
for(int j=0;j<10-i;j++)
27-
{
28-
if(num[j]>num[j+1])
29-
{
30-
temp=num[j];
31-
num[j]=num[j+1];
32-
num[j+1]=temp;
33-
}
34-
}
35-
for(int i=0;i<10;i++)
36-
System.out.print(num[i]+" ");
37-
}
38-
39-
}
1+
package com.algorithm;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
7+
public class JavaSort {
8+
9+
public static void main(String[] args) {
10+
int num[]=new int[100];
11+
String curnum;
12+
BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
13+
for(int i=0;i<10;i++)
14+
{
15+
try {
16+
curnum= read.readLine();
17+
num[i]=Integer.valueOf(curnum);
18+
System.out.print(num[i]+" ");
19+
} catch (IOException e) {
20+
e.printStackTrace();
21+
}
22+
}
23+
System.out.println();
24+
int temp;
25+
for(int i=1;i<10;i++)
26+
for(int j=0;j<10-i;j++)
27+
{
28+
if(num[j]>num[j+1])
29+
{
30+
temp=num[j];
31+
num[j]=num[j+1];
32+
num[j+1]=temp;
33+
}
34+
}
35+
for(int i=0;i<10;i++)
36+
System.out.print(num[i]+" ");
37+
}
38+
39+
}

src/com/algorithm/PrimeNumber.java

100755100644
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
package com.algorithm;
2-
3-
import java.io.BufferedReader;
4-
import java.io.IOException;
5-
import java.io.InputStreamReader;
6-
import java.util.Arrays;
7-
8-
public class PrimeNumber {
9-
10-
public static void main(String[] args) {
11-
boolean a[] = new boolean[10000];
12-
Arrays.fill(a, true);
13-
int i = 0, j = 0;
14-
a[1] = false;
15-
a[2] = true;
16-
for (i = 2; i < 100; i++) {
17-
if (a[i]) {
18-
for (j = i + i; j < 10000; j = j + i)
19-
a[j] = false;
20-
}
21-
}
22-
BufferedReader bReader = new BufferedReader(new InputStreamReader(
23-
System.in));
24-
try {
25-
j = 10;
26-
while (j-- > 0) {
27-
String numString = bReader.readLine();
28-
System.out.println(a[Integer.valueOf(numString)]);
29-
}
30-
} catch (IOException e) {
31-
// TODO Auto-generated catch block
32-
e.printStackTrace();
33-
}
34-
35-
}
36-
37-
}
1+
package com.algorithm;
2+
3+
import java.io.BufferedReader;
4+
import java.io.IOException;
5+
import java.io.InputStreamReader;
6+
import java.util.Arrays;
7+
8+
public class PrimeNumber {
9+
10+
public static void main(String[] args) {
11+
boolean a[] = new boolean[10000];
12+
Arrays.fill(a, true);
13+
int i = 0, j = 0;
14+
a[1] = false;
15+
a[2] = true;
16+
for (i = 2; i < 100; i++) {
17+
if (a[i]) {
18+
for (j = i + i; j < 10000; j = j + i)
19+
a[j] = false;
20+
}
21+
}
22+
BufferedReader bReader = new BufferedReader(new InputStreamReader(
23+
System.in));
24+
try {
25+
j = 10;
26+
while (j-- > 0) {
27+
String numString = bReader.readLine();
28+
System.out.println(a[Integer.valueOf(numString)]);
29+
}
30+
} catch (IOException e) {
31+
// TODO Auto-generated catch block
32+
e.printStackTrace();
33+
}
34+
35+
}
36+
37+
}

src/com/algorithm/TestAsynTreadXunlei.java

100755100644
Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
package com.algorithm;
2-
3-
import java.util.concurrent.atomic.AtomicInteger;
4-
5-
public class TestAsynTreadXunlei {
6-
public static void main(String argv[]) {
7-
8-
AtomicInteger synObj = new AtomicInteger(0);
9-
10-
TestPrint a = new TestPrint(synObj, "A", 0);
11-
TestPrint b = new TestPrint(synObj, "B", 1);
12-
TestPrint c = new TestPrint(synObj, "C", 2);
13-
14-
a.start();
15-
b.start();
16-
c.start();
17-
}
18-
}
19-
20-
class TestPrint extends Thread {
21-
22-
private AtomicInteger synObj;
23-
private String name;
24-
private int flag;
25-
26-
private int count = 0;
27-
28-
public TestPrint(AtomicInteger synObj, String name, int flag) {
29-
this.synObj = synObj;
30-
this.name = name;
31-
this.flag = flag;
32-
}
33-
34-
@Override
35-
public void run() {
36-
while (true) {
37-
synchronized (synObj) {
38-
if (synObj.get() % 3 == flag) {
39-
synObj.set(synObj.get() + 1);
40-
System.out.println(name+synObj.get());
41-
count++;
42-
synObj.notifyAll();
43-
if (count == 10) {
44-
break;
45-
}
46-
} else {
47-
try {
48-
synObj.wait();
49-
} catch (InterruptedException e) {
50-
// TODO Auto-generated catch block
51-
e.printStackTrace();
52-
}
53-
}
54-
}
55-
}
56-
}
1+
package com.algorithm;
2+
3+
import java.util.concurrent.atomic.AtomicInteger;
4+
5+
public class TestAsynTreadXunlei {
6+
public static void main(String argv[]) {
7+
8+
AtomicInteger synObj = new AtomicInteger(0);
9+
10+
TestPrint a = new TestPrint(synObj, "A", 0);
11+
TestPrint b = new TestPrint(synObj, "B", 1);
12+
TestPrint c = new TestPrint(synObj, "C", 2);
13+
14+
a.start();
15+
b.start();
16+
c.start();
17+
}
18+
}
19+
20+
class TestPrint extends Thread {
21+
22+
private AtomicInteger synObj;
23+
private String name;
24+
private int flag;
25+
26+
private int count = 0;
27+
28+
public TestPrint(AtomicInteger synObj, String name, int flag) {
29+
this.synObj = synObj;
30+
this.name = name;
31+
this.flag = flag;
32+
}
33+
34+
@Override
35+
public void run() {
36+
while (true) {
37+
synchronized (synObj) {
38+
if (synObj.get() % 3 == flag) {
39+
synObj.set(synObj.get() + 1);
40+
System.out.println(name+synObj.get());
41+
count++;
42+
synObj.notifyAll();
43+
if (count == 10) {
44+
break;
45+
}
46+
} else {
47+
try {
48+
synObj.wait();
49+
} catch (InterruptedException e) {
50+
// TODO Auto-generated catch block
51+
e.printStackTrace();
52+
}
53+
}
54+
}
55+
}
56+
}
5757
}

0 commit comments

Comments
 (0)