Forked from RTfXGaGeqSeItbMUgpFlekUs/bubblesort-lisplikec.c
Created
June 4, 2010 04:35
-
-
Save nixeagle/424954 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> | |
| #define TRUE 1 | |
| #define FALSE 0 | |
| int bubblesort(int *arr, int len) | |
| { | |
| int i; | |
| int changed; | |
| int done = FALSE; | |
| while (!done) | |
| { changed = FALSE; | |
| for (i = 0; i < len-1; i++) | |
| { if (arr[i] > arr[i+1]) | |
| { tmp = arr[i]; | |
| arr[i] = arr[i+1]; | |
| arr[i+1] = arr[i]; | |
| changed = TRUE; } } | |
| if (!changed) | |
| { done = TRUE; } } } | |
| int main() | |
| { | |
| int arr[5] = {9,3,4,1,2}; | |
| bubblesort(arr, 5); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment