第二次作业

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第二次作业相关的知识,希望对你有一定的参考价值。

import java.util.Scanner;

public class demo {

/**
* @param args 
* 3137102245
* 许聪林
*/
public static void main(String[] args) 
{
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
System.out.println("请输入两个整数:");
int a=0;
int b=0;
try 
{
a=s.nextInt ();
b=s.nextInt();
}
catch (Exception e) 
{
// TODO: handle exception
System.out.println("无公约数!");
}
MaxDivisor m=new MaxDivisor(a,b);
}
}

public class MaxDivisor{
int A;
int B;
int res;

public MaxDivisor(int a,int b){
if(a>0 && b>0)
{
A=a;
B=b;
res = A % B;
}
while(res!=0)
{
A=B;
B=res;
res=A % B;
}

System.out.println(B); 
}

}

 

 
 

以上是关于第二次作业的主要内容,如果未能解决你的问题,请参考以下文章

软件测试作业第二次作业

信号与系统 2023(春季) 作业参考答案 - 第二次作业

第二次作业

第二次作业

第二次作业

第二次作业——题目一