Last active
June 15, 2021 07:56
-
-
Save emadflash/c311e9eba0f30df16ed171f06eae944b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
void print_arr(int* a, int size) { | |
for(int i=0; i < size; ++i) { | |
printf("%d ", a[i]); | |
} | |
} | |
void bubble_sort(int* a, int size) { | |
for(int i=0; i < size; ++i) { | |
for(int j=i + 1; j < size; ++j) { | |
if (a[i] > a[j]) { | |
int temp = a[i]; | |
a[i] = a[j]; | |
a[j] = temp; | |
} | |
} | |
} | |
} | |
int main() { | |
int arr[] = { 1, 12, 9, 100, 8, 2, 4}; | |
bubble_sort(arr, 7); | |
print_arr(arr, 7); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment