您的位置:首页 > 其它

OJ--------最小公倍数+求解立方根

2016-08-11 21:03 211 查看
输入:俩个整数
输出:最小公倍数
样例:2 3
输出:6
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int a=sc.nextInt();
int b=sc.nextInt();

System.out.println(same(a,b));
}

sc.close();
}
private static int same(int a,int b){
int t=a>b?a:b;
int sum=1;
int i=1;
while(!(sum%a==0&&sum%b==0)){
sum=t*i;
i++;
}
return sum;
}
}

求解立方根:

Math.cbrt(scanner.nextDouble());
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: