// bubble sort example #include //#include "platform.h" // platform.h might work on pic32 with "print" instead of "printf" void print(char *str); int a[5]={100, 56, 20, 30, -5}; int i, j; int tmp; int flag; int main() { int a[5]={100, 56, 20, 30, -5}; // init_platform(); printf("Time's up! Let's do this!\n\r"); printf("This is the original array\n\r"); for (i=0; i<5; i++) printf("%10d\n", a[i]); //bubble sort for (j=0; j<4; j++){ flag=0; for (i=0; i<4; i++){ if (a[i]>a[i+1]){ tmp=a[i]; a[i]=a[i+1]; a[i+1]=tmp; flag=1; } } if (flag==0) break; } // should be sorted now printf("This is the ordered array\n\r"); for (i=0; i<5; i++) printf("%10d\n", a[i]); // cleanup_platform(); printf("&a = %p", a); printf("At least I have chicken!\n\r"); return 0; }