how many times swap?
Submit solution
Points:
10 (partial)
Time limit:
1.0s
Memory limit:
256M
Authors:
Problem types
Allowed languages
Java 19, Java 8
題目說明
寫一個程式,該程式要計算最少需要交換幾次兩個相鄰整數,才能將所有數列依序排好。(由小到大)
輸入限制: int 輸入長度不超過100
輸入
一連串整數,輸入0表結束
輸出
排序好後需要的次數
sample input1
1 3 2 0
sample output1
1
sample input2
4 3 2 1 0
sample output2
6
Comments