python计算一个算术题: [1,2,3,4,5]共5个数,组成的3位数乘以2位数,取最大值

 python计算一个算术题: [1,2,3,4,5]共5个数,组成的3位数乘以2位数,取最大值

#!/usr/bin/python
# -*- coding: UTF-8 -*-
x = [1,2,3,4,5]
result_old = 0

for a in x :
    for b in x:
        if b == a : continue
        for c in x:
            if c == a: continue
            if c == b: continue
            for d in x:
                if d == a: continue
                if d == b: continue
                if d == c: continue
                for e in x:
                    if e == a: continue
                    if e == b: continue
                    if e == c: continue
                    if e == d: continue
                    result_curr = (a*100 + b*10 + c) * (d*10 + e)
                    if result_old < result_curr:
                        result_old = result_curr
                        old_a = a
                        old_b = b
                        old_c = c
                        old_d = d
                        old_e = e

print("%r%r%r X %r%r = %d" % (old_a, old_b, old_c, old_d, old_e, result_old))

 

 

    原文作者:dbitc
    原文地址: https://blog.csdn.net/dbitc/article/details/84262035
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞