def compute(a, b): while b!= 0: t = b b = a % b a = t return a x, y = eval(input()) m, n = eval(input()) a = (x*n + y *m) b = y * n gcd = compute(a, b) a = a / gcd b = b / gcd print('%d/%d + %d/%d = %d/%d'%(x,y,m,n,a,b))
Category: Python
全新的繁體中文 WordPress 網站
def compute(a, b): while b!= 0: t = b b = a % b a = t return a x, y = eval(input()) m, n = eval(input()) a = (x*n + y *m) b = y * n gcd = compute(a, b) a = a / gcd b = b / gcd print('%d/%d + %d/%d = %d/%d'%(x,y,m,n,a,b))