I was solving a collection of paiza level-up questions, but I didn't have a model answer, so I made it myself. The language is Python3.
Sorting the number of Paiza skill check sample questions (equivalent to paiza rank D) https://paiza.jp/works/mondai/skillcheck_sample/sort-number?language_uid=python3 I couldn't see the problem statement without logging in. Registration is free and can be done immediately, so I recommend you to register for the time being.
I wrote the bubble sort myself.
sort-number.py
#Save the entered value
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
#Bubble sort
def bSort(a):
for i in range(len(a)-1):
for j in range(len(a)-1, i, -1):
if a[j] < a[j-1]:
a[j], a[j-1] = a[j-1], a[j]
return a
#Output the answer
for i in bSort(a):
print(i)
https://qiita.com/KoyanagiHitoshi/items/3286fbc65d56dd67737c
Feel free to comment if you have any questions. I will answer as much as possible!
Recommended Posts