Created
October 17, 2009 00:59
-
-
Save dchiji/212178 to your computer and use it in GitHub Desktop.
This file contains 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> | |
#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