use new fname

This commit is contained in:
kevinnls committed 2021-09-20 16:44:01 +05:30
1 parent f470cca975
commit 78e466eb0f
1 file changed
+11 -11
+11 -11
View File
@@ -1,7 +1,7 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "../debug/debug.h"
#include "../_headers/debug.h"
int* sort(int*, int);
void swap(int*, int, int);
@@ -35,12 +35,12 @@ int main(int argc, char** argv){
int* sort(int* arr, int length){
if(DEBUG){
dprintf("length of array to be sorted: %d\n", length);
dprintf("elements of array to be sorted: ");
debug_msg("length of array to be sorted: %d\n", length);
debug_msg("elements of array to be sorted: ");
for(int i=0; i<length; i++){
if(i!=0) printf(", ");
dprintf("%d", arr[i]);
debug_msg("%s%d", i==0?"":", ",arr[i]);
}
debug_msg("\n");
}
int changes = 0;
@@ -48,7 +48,7 @@ int* sort(int* arr, int length){
changes = 0;
for(int i=0; i<length-1; i++){
if(arr[i]>arr[i+1]){
if(DEBUG) dprintf("need to swap [%d]->%d and [%d]->%d\n",i,arr[i],i+1,arr[i+1]);
if(DEBUG) debug_msg("need to swap [%d]->%d and [%d]->%d\n",i,arr[i],i+1,arr[i+1]);
swap(arr, i, i+1);
++changes;
}
@@ -56,23 +56,23 @@ int* sort(int* arr, int length){
} while (changes != 0);
if(DEBUG){
dprintf("=====\nelement post-sort are: ");
debug_msg("=====\nelement post-sort are: ");
for(int i=0; i<length; i++){
if(i!=0) printf(", ");
dprintf("%d", arr[i]);
debug_msg("%s%d", i==0?"":", ",arr[i]);
}
debug_msg("\n");
}
return arr;
}
void swap(int* arr, int left, int right){
if(DEBUG)
dprintf("PRESWAP left[%d] is: %d; right[%d] is %d\n", left,arr[left],right,arr[right]);
debug_msg("PRESWAP left[%d] is: %d; right[%d] is %d\n", left,arr[left],right,arr[right]);
int _hold = arr[left];
arr[left] = arr[right];
arr[right] = _hold;
if(DEBUG)
dprintf("POSTSWAP left[%d] is: %d; right[%d] is %d\n", left,arr[left],right,arr[right]);
debug_msg("POSTSWAP left[%d] is: %d; right[%d] is %d\n", left,arr[left],right,arr[right]);
}
void integeriseArgs(int len, char** args, int* arr_ptr){