赞
踩
python代码一
# fractions这个库是python自带的可以用来约分的库
from fractions import Fraction
list_1 = list(map(int,input().split()))
list_1 = sorted(list_1)
a1,a3 = list_1[0],list_1[2]
a = Fraction(a1, a3)
print(a)
python代码二
a = input().split(' ')
a = [int(i) for i in a]
a = sorted(a)
a1 = a[0]
a3 = a[2]
# 约分
while a1:
yushu = a3%a1
a3 = a1
a1 = yushu
print ("%d/%d"%(a[0]/a3,a[2]/a3))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。