Please write a Java program,compute the GreatestCommonDiviso
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/06/13 14:13:34
Please write a Java program,compute the GreatestCommonDivisor
求JAVA程序
求JAVA程序
// m,n > 0
public class Test {
\x05public static void main(String[] args){
\x05\x05Test t = new Test();\x05\x05
\x05\x05System.out.println(t.getGreatestCommonDivisor(36,8));\x05\x05
\x05}
\x05public int getGreatestCommonDivisor(int m,int n) {
\x05 if(m < n) {
\x05 int temp = 0;
\x05 temp = m;
\x05 m = n;
\x05 n = temp;
\x05 }
\x05 int r = m % n;
\x05 while(r != 0){
\x05 m = n;
\x05 n = r;
\x05 r = m % n;
\x05 }
\x05 return n;
\x05}
}
public class Test {
\x05public static void main(String[] args){
\x05\x05Test t = new Test();\x05\x05
\x05\x05System.out.println(t.getGreatestCommonDivisor(36,8));\x05\x05
\x05}
\x05public int getGreatestCommonDivisor(int m,int n) {
\x05 if(m < n) {
\x05 int temp = 0;
\x05 temp = m;
\x05 m = n;
\x05 n = temp;
\x05 }
\x05 int r = m % n;
\x05 while(r != 0){
\x05 m = n;
\x05 n = r;
\x05 r = m % n;
\x05 }
\x05 return n;
\x05}
}
Please write a Java program,compute the GreatestCommonDiviso
英语翻译Write a program to compute the interest due,total amount
Write a program,which performs as the following:(java)
Java write a program to calculate the sum of each of the ser
Java write a program to read an integer,n,from the keyboard
Java write a program to calculate the factorial of any natur
关于java编程问题Write an algorithm and a program to settle the fol
how to write this java program
how to write this java program?
write a program to represent multiplication tables.用最简单的JAVA
how to show the download speed in KB/s in a java program
when you finish your document,please s_____it on the compute