⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort.java

📁 Java经典例程 从外国一大学计算机教授出版物下载的代码 经典
💻 JAVA
字号:
package myutilities;

public class Sort {

    /* The Sort class   by J M Bishop  Feb 1997
     *                  revised October 1997
     * Provides one sorting method
     * for arrays of objects of any length.
     * where the objects' class implements the
     * Sortable interface.
     */

  public static void selectionSort(Sortable a [], int n) {
    Sortable temp;
    int chosen;

    for (int leftmost = 0; leftmost < n-1; leftmost++) {
      chosen = leftmost;
      for (int j = leftmost+1; j < n; j++) {
        if (a[j].lessThan(a[chosen])) {
          chosen = j;
        }
      }
      temp = a[chosen];
      a[chosen] = a[leftmost];
      a[leftmost] = temp;
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -