分数化简 int x = a,y = b,r; if(a == b) { System.out.println(1); return; } while(y!=0) { r = x%y; x=y; y=r; } a/=x; b/=x; System.out.println(a + "/" + b);