輸入一組數字,中間以逗號隔開,數字越大優先級越高,0優先級最高,按輸入的數字,列印優先級,數字相同時前面1個數字的優先級高于后面1個數字
樣例:
輸入 1,3,3,2
輸出 3,0,1,2
if __name__ == '__main__':
s = input().split(',')
s1 = list(sorted(s,reverse=True))
result = []
popties =[x for x in range(len(s))]
for x in s:
tmp = s1.index(x)
result.append(popties[tmp])
s1.pop(tmp)
popties.pop(tmp)
print(result)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/105985.html
標籤:Python
上一篇:Python進行企業資產狀況分析
