菜鸟问题高手们帮忙解决下
求两个数的最大公约数和最小公倍数,大家帮我看看代码问题出在那?谢谢
class A3
{
public int f(int a,int b)
{
int c;
c=a%b;
while(c!=0)
{
a=b;
b=c;
c=a%b;
}
return b;
}
}
class B3 extends A3
{
public int f(int a,int b)
{
int m;
m=super.f(int a,int b);
return (a*b)/m;
}
}
public class E3
{
public static void main(String args[])
{
A3 a3=new A3();
B3 b3=new B3();
System.out.println( "最大公约数是: "+a3.f(4,2));
System.out.println( "最大公倍数是: "+b3.f(4,2));
}
}
------解决方案--------------------是m=super.f(a,b);
不是m=super.f(int a,int b);