马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
军火展示:def plus(a, b):
return (str(a) + '+' + str(b) + '=' + str(abs(a) + abs(b))) if a > 0 and b > 0 else ('(' + str(a) + ') + (' + str(b) + ')=' + str(-(abs(a) + abs(b)))) if a < 0 and b < 0 else (str(a) + ' + (' + str(b) + ')=' + str(a - abs(b))) if a > 0 and b < 0 and abs(a) > abs(b) else (str(a) + ' + (' + str(b)+ ')=' + str(-(abs(b) - a))) if a > 0 and b < 0 else ('(' + str(a) + ') +' + str(b) + '=' + str(-(abs(a) - b))) if a < 0 and b > 0 and abs(a) > abs(b) else ('(' + str(a) + ') +' + str(b) + '=' + str(b - abs(a))) if a < 0 and b > 0 else (str(a) + '+' + str(b) + '=' + str(b)) if a == 0 else (str(a) + '+' + str(b) + '=' + str(a))
print(*plus(1,1))
只有三行,非常简洁,遥遥领先于C++( |