Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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