Last active
September 23, 2020 02:54
-
-
Save czwen/44c6df6f41843f24f20d04a7b9559638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <stdio.h> | |
void bubbleSort(int arr[], int length){ | |
for (int i = 0; i < length-1; ++i) | |
{ | |
for (int j = 0; j < length-1-i; ++j) | |
{ | |
if (arr[j]>arr[j+1]) | |
{ | |
int temp = arr[j]; | |
arr[j] = arr[j+1]; | |
arr[j+1] = temp; | |
} | |
} | |
} | |
} | |
int main(){ | |
int arr[] = {2,3,4,1,7,2,4,7,9}; | |
int n = 9; | |
bubbleSort(arr, n); | |
for (int i = 0; i < n; ++i) | |
{ | |
printf("%d\n", arr[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment