From 734fea77a6423ed8bbd176b45bdb2877aa997c8f Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 22 Apr 2024 09:50:15 +0400 Subject: [PATCH] 6 remove unneded variable --- The Last Algorithms Course You'll Need/6. Bubble Sort.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/The Last Algorithms Course You'll Need/6. Bubble Sort.c b/The Last Algorithms Course You'll Need/6. Bubble Sort.c index 6e912c6..201669b 100644 --- a/The Last Algorithms Course You'll Need/6. Bubble Sort.c +++ b/The Last Algorithms Course You'll Need/6. Bubble Sort.c @@ -22,10 +22,9 @@ void bubble_sort(int array[], int size) { - int shift = 0; for (int i = 1; i < size; ++i) { - for (int j = 1; j < size - shift; ++j) + for (int j = 1; j < size - i; ++j) { if (array[j] < array[j-1]) { @@ -34,7 +33,6 @@ void bubble_sort(int array[], int size) array[j-1] = temp; } } - ++shift; } }