[Python P1116]鄙人有所不知,望请各位高手指点

P1116 车厢重组

希望更丰富的展现?使用Markdown
by orange_dream @ 2022-01-03 17:31:53


```py a=int(input()) b=list(map(int,input().split())) c=0 for d in range(a): for e in range(0, a-d-1): if b[e] > b[e+1] : b[e], b[e+1] = b[e+1], b[e] c=c+1 print(c) ```
by a1ioua @ 2022-01-03 17:36:39


```python a=int(input()) b=[] while len(b)<a: b+=[int(i) for i in input().split()] c=0 for d in range(a): for e in range(0, a-d-1): if b[e] > b[e+1] : b[e], b[e+1] = b[e+1], b[e] c=c+1 print(c) ``` @[Horizon208](/user/657540) 不是你的问题,数据没有都写在第二行上。(日常刁难Python玩家)
by Terrible @ 2022-01-03 20:06:37


其实不用冒泡算法
by AppleSupporter @ 2022-08-21 17:20:03


直接计算位置
by AppleSupporter @ 2022-08-21 17:20:30


|