#include #include #include int* sort(int*, int); void swap(int*, int, int); int DEBUG; int main(){ char* _debug = getenv("DEBUG"); if(_debug) DEBUG = !strcmp(_debug,"1"); //how does this even work??? int arr[] = {1,2,3,6,5}; int arr_len = sizeof(arr) / sizeof(arr[0]); sort(arr, arr_len); printf("\n"); return EXIT_SUCCESS; } int* sort(int* arr, int length){ if(DEBUG){ printf("length of array to be sorted: %d\n", length); printf("elements of array to be sorted: "); for(int i=0; iarr[i+1]){ if(DEBUG)printf("need to swap [%d]->%d and [%d]->%d\n",i,arr[i],i+1,arr[i+1]); swap(arr, i, i+1); ++changes; } } } while (changes != 0); if(DEBUG){ printf("=====\nelement post-sort are: "); for(int i=0; i