Luogu question writing Python language | P5715 Three-digit sorting

Learn Python from a young age! Record the questions in the Luogu Python learning and exam preparation process, and record every moment.

Attached is a summary post: Luogu’s Python language | Summary_Blog of a communicator who loves programming-CSDN Blog


[Title description]

Given three integers a, b, c (0≤ a , b , c ≤100), it is required to sort these three integers from small to large.

【enter】

Enter three integers a, b, c, separated by spaces.

【Output】

Output one line, three integers, indicating the sorted results from small to large.

【Input sample】

1 14 5

【Output sample】

1 5 14

[Detailed code explanation]

a, b, c = [int(i) for i in input().split()]  
if a > b: 
    a, b = b, a  
if b > c:  
    b, c = c, b 
if a > b:  
    a, b = b, a 
print(a, b, c)

【operation result】

1 14 5
1 5 14

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/132777884