You Gotta try this...
Site is in beta but works in browsers. Android App available too.
http://www.sourceLair.com
This is a SORT example and here's the output:
Before shellsort: 83 86 77 15 93 35 86 92 49 21
After shellsort: 15 21 35 49 77 83 86 86 92 93
Try this or your own code, of course...
#include <stdio.h>
#define MAXARRAY 10
void shellsort(int a[], int total, int index);
int main(void) {
int array[MAXARRAY] = {0};
int i = 0;
/* load some random values into the array */
for(i = 0; i < MAXARRAY; i++)
array = rand() % 100;
/* print the original array */
printf("Before shellsort: ");
for(i = 0; i < MAXARRAY; i++) {
printf(" %d ", array);
}
printf("\n");
shellsort(array, MAXARRAY, 1);
/* print the `shellsorted' array */
printf("After shellsort: ");
for(i = 0; i < MAXARRAY; i++) {
printf(" %d ", array);
}
printf("\n");
return 0;
}
void shellsort(int a[], int total, int index) {
int i = 0;
int j = 0;
int k = 0;
int l = 0;
for(k = 0; k < index; k++) {
for(i = k; i < total; i += index) {
l = a;
for(j = (i - index); j >= 0; j -= index) {
if(a[j] > l)
a[j + index] = a[j];
else
break;
}
a[j + index] = l;
}
}
return;
}
Acknowledgement for the code goes to Fahad Uddin --
http://www.mycsnippets.blogspot.com/sea ... el/sorting
Free cloud compiling at sourceLair.com
- dennis-slacko531
- Posts: 100
- Joined: Wed 18 Jan 2012, 21:53
- Location: Oregon
- Contact:
Other sites too...
http://ellcc.org/demo also has an online C compiler, though it just makes an ASM listing.
(ellcc is LLVM/Clang for embedded work)
(ellcc is LLVM/Clang for embedded work)