From 0170979d75b959b582279d4f7d384c0be11878ae Mon Sep 17 00:00:00 2001 From: qyguo Date: Fri, 5 Jan 2024 10:46:02 +0800 Subject: [PATCH] 1 --- test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..3309710 --- /dev/null +++ b/test.py @@ -0,0 +1,12 @@ +def bubble_sort(arr): + n = len(arr) + for i in range(n): + for j in range(0, n - i - 1): + if arr[j] > arr[j + 1]: + arr[j], arr[j + 1] = arr[j + 1], arr[j] + + +# Example usage +arr = [64, 34, 25, 12, 22, 11, 90] +bubble_sort(arr) +print("Sorted array:", arr)