Skip to content

Instantly share code, notes, and snippets.

@dchiji
Created October 17, 2009 00:59
Show Gist options
  • Save dchiji/212178 to your computer and use it in GitHub Desktop.
Save dchiji/212178 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
int main()
{
int lis[MAX];
int n = 0;
int j = 0;
for(int i = 0; i< MAX; i++) {
lis[i] = rand();
}
for(int i = 0; i < MAX && j < MAX; i++) {
for(j = i; j < MAX; j++) {
if(j != 0) {
if(lis[j] < lis[j - 1]) {
n = lis[j - 1];
lis[j - 1] = lis[j];
lis[j] = n;
j = j - 2;
}
}
}
}
for(int k = 0; k < MAX; k++) {
printf("%d ", lis[k]);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment