2019-03-10 分数求和

#include
#include
#include
using namespace std;
const int maxn = 100;
int x[maxn],y[maxn];
int Gcd(int m,int n)
{
    if(m> n;
    int lcm=1,gcd,sum=0;
    for(int i=0;i>x[i]>>y[i];
        lcm=Lcm(lcm,y[i]);
        sum+=x[i]*(y[i]/x[i]);
    }
    gcd=Gcd(lcm,sum);
    int xx=sum/gcd;
    int yy=lcm/gcd;
    printf("%d/%d",xx,yy);
    return 0;
} 

你可能感兴趣的:(2019-03-10 分数求和)