diff options
author | standenboy <standenboy@seacrossedlovers.xyz> | 2024-04-19 10:31:01 +0100 |
---|---|---|
committer | standenboy <standenboy@seacrossedlovers.xyz> | 2024-04-19 10:31:01 +0100 |
commit | a241ad8e874a2220d81254c2ebfbe69d0470fd9b (patch) | |
tree | d8ac8e8cfdedd03554e0cb92452784e8af8f3bee /comp/work/30/bubble.py | |
parent | c696b4d6ded69074cd08c51b91eabeaeac5823ac (diff) |
added a few bits
Diffstat (limited to 'comp/work/30/bubble.py')
-rw-r--r-- | comp/work/30/bubble.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/comp/work/30/bubble.py b/comp/work/30/bubble.py new file mode 100644 index 0000000..e152c7d --- /dev/null +++ b/comp/work/30/bubble.py @@ -0,0 +1,20 @@ +import sys + +def bubble(list): + length = len(list) + for i in range(length - 1): + for j in range(length - i - 1): + if list[j] > list[j+1]: + tmp = list[j] + list[j] = list[j+1] + list[j+1] = tmp + return list + + +count = int(sys.argv[1]) + +num = [] +for i in range(count): + num.append(int(input(f"number {i}: "))) + +print(bubble(num)) |