Example of permutation and combination

Case 1: Permutation and Combination

Require:

List all possible combinations of 4 numbers that are different from each other without repeating numbers.

analyze:

What's there to analyze... just sort it out

for i in range(1,5):
    for j in range(1,5):
        for k in range(1,5):
            if( i != k ) and (i != j) and (j != k):
                print(i,j,k)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325115065&siteId=291194637