#include <stdio.h> void swap(int *a, int *b); void sort(int *a, int n); void show(int *a, int n); int main() { int a[] = {4,7,3,1,4,2}; int n = sizeof(a)/sizeof(int); printf("%ld ",sizeof(int)); sort(a , n); show(a , n); printf(" "); int z[] = {4,1}; sort(z,2); show(z,2); } void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } void sort(int *a, int n) { int *p1,*p2,j; for(p1 = a , p2 = a+1 , j = 1; p2 < a + n; p1++,p2++,j++) { for ( int i = 0; i < n - j; i++) { if (*p1 > *(p2+i)) { //printf("-->%d,%d ",*p1,*(p2+i)); swap(p1,p2+i); //show(a,n); } } } } void show(int *a, int n) { for(int i = 0; i < n; i++) { printf("%d ",a[i]); } printf(" "); }