3-20java's time
来源:互联网 发布:赢时胜期货软件下载 编辑:程序博客网 时间:2024/06/06 14:15
No matter how ,today's studing is a harvest! first of all,rather than look at the answer of the Algorithm question,i can littlely have thought and in some time .the result turns out myself's idea is more Wisdom,haha.so it is a valuable words:just believe youself without anything else.
beside the Grammar and Mode,or anything other,using the java language to solve the question of life and learning and trying to make a better solution is a great enjoy without saying .and it is also a wayto make a difference,in a meaning this can lead to a great difference in the furture sooner or latter.may be do youself best is on the way of trying tomake a difference and enjoy ourself.Great isn't it?!
in one word ,just do it! I LOVE JAVA!
ONE OF THE Algorithm:to find the Greatest common divisor of two rand nums;to find the Least common multiple of two rand nums;
import java.util.Scanner;
//最小公倍数=积/最大公约数!!!!!!
public class GongyueshuGongbeishu {
public static void main(String[] args) {
int[] grade = new int[2];
int m, n;
int min;
Scanner scanner = new Scanner(System.in);
for (int i = 0; i < 2; i++) {
grade[i] = scanner.nextInt();
}
if (grade[0] > grade[1]) {
m = grade[0];
n = grade[1];
} else {
n = grade[0];
m = grade[1];
}
int i = 1;
while (m <= m * n) {
if ((m * i) % n == 0) {
System.out.println("最小公倍数:" + m * i);
System.out.println("最大公约数:" + m * n / (m * i));
break;
} else {
i++;
}
}
int j = 1;
while (n / j >= 1) {
if (n % j == 0 && m % (n / j) == 0) {
System.out.println("最大公约数:" + n / j);
System.out.println("最小公倍数:" + m * n / (n / j));
break;
} else {
j++;
}
}
}
}
- 3-20java's time
- it 's time to turn to java
- Schumacher: It's time
- It's show time!!!
- It’s Android Time
- It’s Android Time
- It's time
- It's Time
- It's Time 2
- It's time
- It's time!
- java--time
- JAVA [Time]
- It’s time to rise
- It's time to sleep
- show server's time dynamically
- It's time to start
- aspectj's load-time instrumentation
- CRC 算法代码
- POCO C++库学习和分析 -- 文件系统
- Could not open the editor: can not change undo manager once its been set
- 电脑键盘KeyCode值
- 2012-03-01 21:15 DM368 NAND Flash启动揭秘
- 3-20java's time
- json与string相互转换
- POCO C++库学习和分析 -- 日志 (一)
- POCO C++库学习和分析 -- 流 (一)
- Oracle完全卸载
- OMAPL138/AM1808片上PRU指令集
- Hibernate 常见错误
- $_FILES 的用法
- 字符串分割多个空格(用正则)