我们需要找出分子分母的最大公约数
用OC来写这个函数
- (void) reduce
{
int a = molecular; //a是分子
int b = denominator; //b是分母
int temp;
while(a!=0){
temp = a % b;
a = b; //通过循环找到最大公约数a
b = temp;
}
molecular /=a; //分子分母都同除a,约简
denominator /=a;
}