3、ance(Ballball1,Ballball2){if(ball1.getWeight()==ball2.getWeight()){return0;}elseif(ball1.getWeight()>ball2.getWeight()){return1;}else{20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electr
4、onic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelenderreturn2;}}/***算出哪一个不一样,是重了还是轻了*@paramballs*@return*/publicvoidbalanceMethod(Ball[]balls){Ball[]A={balls[0],balls[1],balls[2],balls[3]};Ball[]B={balls[4]
5、,balls[5],balls[6],balls[7]};Ball[]C={balls[8],balls[9],balls[10],balls[11]};//1.称第一次intfirst=balance(A,B);if(first==0){//A==B,C组中有问题Ball[]D=newBall[3];Ball[]E=newBall[3];for(inti=0;i<3;i++){D=A;E=C;}//2.称第二次intsecond=balance(D,E);if(second==0){//D,E相等,C
6、中第4个有问题//3.称第三次intthird=balance(A[0],C[3]);System.out.println("第12个球有问题!"+(third==2?"这个球重了!":"这个球轻了!"));}else{//3.称第三次intthird=balance(C[0],C[1]);if(third==0){System.out.println("第11个球有问题!"+(third==2?"这个球重了!":"这个球轻了!"));}else{if(second==1){if(third==1){S
7、ystem.out.println("第10个球有问题!这个球轻了!");}else{System.out.println("第9个球有问题!这个球轻了!");}20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certificate
8、bondsapplyformortgageloans,acceptingonlythelender}else{if(third==1){System.out.println("第9个球有问题!这个球重了!");}else{System.out.println("第10个球有问题!这个球重了!");}}}}}else{Ball[]D={A[0],A[1],B[0],C[0]};Ball[]E={A[2],A[3],B[1],C[1]};//2