Skip to content

Instantly share code, notes, and snippets.

@voldmar
Created November 25, 2010 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voldmar/715297 to your computer and use it in GitHub Desktop.
Save voldmar/715297 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
int main()
{
int m[]={2, 8, 6, 5, 1};
int i, j, temp;
for (i = 1; i < sizeof(m) / sizeof(int); i++) {
for (j = 0; j < i; j++) {
if (m[j] > m[i]) {
temp = m[j];
m[j] = m[i];
m[i] = temp;
}
}
}
for (i = 0; i < sizeof(m) / sizeof(int); i++) {
printf("m[%d] = %d\n", i, m[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment