c++语言、输入两个正整数m和n,求其最大公约数和最小公倍数。
2个回答
展开全部
import java.util.Scanner;
public class Divisor1 {
//static int m;
//static int n;
int a,b;
public static void main(String[]args){
//输入两个数m,n
System.out.println("请输入第一个数m=");
Scanner in = new Scanner(System.in);
int m = in.nextInt();
System.out.println("请输入第二个数n=");
int n = in.nextInt();
int r;
while(n!=0){
r = m%n;
m = n;
n = r;
}
System.out.println(m);
public class Divisor1 {
//static int m;
//static int n;
int a,b;
public static void main(String[]args){
//输入两个数m,n
System.out.println("请输入第一个数m=");
Scanner in = new Scanner(System.in);
int m = in.nextInt();
System.out.println("请输入第二个数n=");
int n = in.nextInt();
int r;
while(n!=0){
r = m%n;
m = n;
n = r;
}
System.out.println(m);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询