📄 hcfrepeat.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 + -