#coding: utf-8 def pandq(i): tmp = [] for t in range(i): if t < i - t: tmp.append([t, i-t]) return tmp def yukisort(n, list): lst = range(2*n-3) for t in lst: pandqList= pandq(t) for pq in pandqList: if pq[1] < n: if list[pq[0]] > list[pq[1]]: tmp = list[pq[0]] list[pq[0]] = list[pq[1]] list[pq[1]] = tmp else: pass print list if __name__ == "__main__": print "配列の要素数を入力してください" n = input() print "要素数nの配列を(空白区切りで)入力してください" a = [] while len(a) != n: a = map(int, raw_input().split()) if len(a) != n: print "要素数が合いません.もう一度入力してください" yukisort(n, a)