Bubble Sort Code:
Bubble sort Void arr () { int arr[] = {3,2,4,1}; int count = sizeof (arr)/sizeof (arr[0]); for (int i=0; i< count-1; i++) { for (int j=0; j< count-i-1; j++) { if (arr[j]<arr[j+1]) { int temp; temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } for (int x = 0; x<count; x++) { printf ("Count=%i,value=%i\ N ", Count,arr[x]); } }
Sort the bubbles of pointers:
Void pointarr () { int arr[] = {5,4,6,2,7,1,3}; int count = sizeof (arr)/sizeof (arr[0]); int *pointer; pointer = arr; for (int i = 0; i<count-1; i++) { for ( int j = 0; j<count-i-1; j++) { if (* (pointer+j) <* (pointer+j+1)) { int tem; tem = * (POINTER+J); * (POINTER+J) = * (pointer+j+1); * (pointer+j+1) = tem; } } } for (int x = 0; x<count; x++) { printf ("count=%i,value=%i\n", Count,arr[x]); } }
Select the sort code:
Void selectarr () { int arr[] = {4,3,5,2,10,50,20,45}; int count = sizeof (arr)/sizeof (arr[0]); for (int i = 0; i<count-1; i++) { for (int j = i+1; j<count; j++) { if (Arr[i]>arr[j]) { int temp; temp = arr[i]; arr[i] = arr[j]; arr[j]= temp; } } } for (int x = 0; x<count; x++) { printf ("count= %i,value=%i\n ", Count,arr[x]); } }
C-language bubbling and selection sorting