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

📄 hcfrepeat.java

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

class HCFRepeat {

  /* The HCF Program      by J M Bishop Aug 1996
   * ===============      Display version July 1999
   *                      updated May 2000
   * Calculates the highest common factor of two integers.
   * Illustrates a while loop.
   */

  HCFRepeat () {
    Display display = new Display("HCF");
    display.println("***** Finding the HCF *****");
    display.prompt("Integer a", 567);
    display.prompt("Integer b", 123);
    int a, b;

    while (true) {
      display.ready("Press ready when data has been entered");
      a = display.getInt("Integer a");
      b = display.getInt("Integer b");
      display.println("a\tb");

      while (a != b) {
        display.println(Stream.format(a,6)+"\t"+Stream.format(b,6));
        if (a > b) {
          a -=b;
        } else {
          b -=a;
        }
      }
      display.println("The HCF is " + a);
      display.ready("Press ready for another data set");
    }
  }

  public static void main (String args []) {
    new HCFRepeat();
  }
}

⌨️ 快捷键说明

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