📄 sorttestint.java
字号:
import java.io.*;
import javagently.*;
import myutilities.*;
class SortTestInt {
/* The SortTesInt program by J M Bishop Dec 1996
* Java 1.1 October 1997
* revised August 2000
* for sorting a table of integers
* Illustrates linking up to an independent sorter.
* as well as putting integers in envelopes.
*/
public static void main(String[] args) throws IOException {
new SortTestInt();
}
SortTestInt () throws IOException {
OurInteger[] t = new OurInteger[10];
Stream in = new Stream(System.in);
for (int i = 0; i < 10; i++)
t[i] = new OurInteger(in.readInt());
System.out.println("Original");
System.out.println("========");
for (int i = 0; i < t.length; i++) {
System.out.print(t[i].val+" ");
}
System.out.println();
Sort.selectionSort(t,t.length);
System.out.println();
System.out.println("Sorted");
System.out.println("======");
for (int i = 0; i < t.length; i++) {
System.out.print(t[i] +" ");
}
System.out.println();
}
class OurInteger implements Sortable {
/* This member class encapsulates an integer
* as an object and implements Sortable
* for integers.
*/
int val;
public OurInteger(int i) {
val = i;
}
public boolean lessThan(Sortable a) {
OurInteger i = (OurInteger)a;
return val < i.val;
}
public String toString () {
return String.valueOf(val);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -