Skip to content

Instantly share code, notes, and snippets.

@voldmar
Created November 25, 2010 12:22
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/715305 to your computer and use it in GitHub Desktop.
Save voldmar/715305 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
int main()
{
int m[5]={2, 8, 6, 5, 1};
int i = 1, j, c;
while (i < 5) {
j = 0;
while (j < i) {
if (m[j] > m[i]) {
c = m[j];
m[j] = m[i];
m[i] = c;
}
j++;
}
i++;
}
printf("m[0] = %d\n", m[0]);
printf("m[1] = %d\n", m[1]);
printf("m[2] = %d\n", m[2]);
printf("m[3] = %d\n", m[3]);
printf("m[4] = %d\n", m[4]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment