From 11ab56686715de336f1ac593f75fc1dbd509194c Mon Sep 17 00:00:00 2001 From: kevinnls <57634663+kevinnls@users.noreply.github.com> Date: Mon, 20 Sep 2021 02:31:04 +0530 Subject: [PATCH] implement basic sorting --- bubblesort/main.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bubblesort/main.c b/bubblesort/main.c index 6613109..39233ee 100644 --- a/bubblesort/main.c +++ b/bubblesort/main.c @@ -3,6 +3,7 @@ #include int* sort(int*, int); +void swap(int*, int, int); int DEBUG; int main(){ @@ -30,5 +31,27 @@ int* sort(int* arr, int length){ } } + for(int i=1; iarr[i+1]) + swap(arr, i, i+1); + } + + if(DEBUG){ + printf("=====\nelement post-sort are: "); + for(int i=0; i