组队成员: 仇夏
学号: 20172310
结对照片:
博客地址:点击这里java
> public class Fraction { > private int a,b; > private int num1; > private int num2; > private String result; > private int tem=1;//两数最大公约数 > > > public Fraction( ) > { > getRandom(); > while (num1==num2) {//当分子分母相同就一直使用getRandom()方法得到num1,num2直到num1!=num2。 > getRandom(); > } > a=Math.min(num1,num2); > b=Math.max(num1,num2);//让a,b分别取较小值和较大值 > > tem=a; > > while (tem>=1) > { > if (num1%tem==0&&num2%tem==0) > break; > > tem--; > }//获得最大公约数 > > a=a/tem; > b=b/tem; > result=a+"/"+b;//获得约分后的分数 > > } > > private void getRandom(){ > num1 = (int)(Math.random()*9+1); > num2 = (int)(Math.random()*9+1); > }//一个方法,让num一、num2分别取1~9中的随机数 > > public String getResult() > { > return result; > } > }
int count1=0,count; double accuracy; accuracy=count1/count;//更改之前 accuracy=(double)count1/count;//更改之后