import java.util.Scanner;
public class C{
public static int fun1(int a1,int b1){
int c;
c=a1%b1;
while (c>0)
{a1=b1;
b1=c;
c=a1%b1;
//return b1;
}
return b1; //把return写在这里;
}
public static void main(String[] args) {
int a,b,temp;
int m;
Scanner in=new Scanner(System.in);
a=in.nextInt();
b=in.nextInt();
if(a
java 求最大公约数,最小公倍数
java 求最大公约数,最小公倍数
利用辗转相除法求两个整数的最大公约数和最小公倍数.注意,这里只写一个方法求最大公约数,最小公倍数放到main方法中完成.
import java.util.Scanner;
public class Chpt7_4 {
public static int fun1(int a1,int b1)
{ int c;
c=a1%b1;
while (c>0)
{a1=b1;
b1=c;
c=a1%b1;
return (b1);
}
}
public static void main(String[] args) {
int a,b,temp;
int m;
Scanner in=new Scanner(System.in);
a=in.nextInt();
b=in.nextInt();
if(a
利用辗转相除法求两个整数的最大公约数和最小公倍数.注意,这里只写一个方法求最大公约数,最小公倍数放到main方法中完成.
import java.util.Scanner;
public class Chpt7_4 {
public static int fun1(int a1,int b1)
{ int c;
c=a1%b1;
while (c>0)
{a1=b1;
b1=c;
c=a1%b1;
return (b1);
}
}
public static void main(String[] args) {
int a,b,temp;
int m;
Scanner in=new Scanner(System.in);
a=in.nextInt();
b=in.nextInt();
if(a
其他人气:656 ℃时间:2019-10-17 03:22:47
优质解答
我来回答
类似推荐
猜你喜欢
- 1固体酒精熔点为摄氏零下117度,那么摄氏零下116度,摄氏零下118,那么它又是什么状态?为什么?
- 2快乐的星期天作文 450字急!
- 3选择:I ___ the weather here after I live in the city for thre weeks.
- 4我正在考虑飞往上海而不是乘火车.I'm think about ______to Shanghai rather than ______there ___train.
- 5在周长31千米的花坛周围铺一条1米宽的石子路,这条石子路的面积是多少平方米?
- 6这是我的连衣裙.那是你的T恤衫.用英语说
- 7与顾章书和与朱元思书都描写了山中的各种声音,其表达作用是什么
- 8镁为什么会和氯化铁溶液反应生成氢气?
- 92-2的平方-2的三次方-2的四次方-…-2的九次方+2的十次方
- 10高速公路上,一辆长为3.5米的小汽车正以每秒45米的速度行驶,前方一长为16.5米的大货车正以每秒35米的速度同向行驶,小汽车追上大货车的超车时间是多少?