1 #include <stdio.h> 2 #include <stdlib.h> 3 #define M 6 4 void main() 5 { 6 int a[M] = { 0 }; 7 int i, j; 8 int tmp=0; 9 printf("please input the data: "); 10 for (i = 0; i < M; i++) 11 scanf("%d", &a[i]); 12 for (i = 0; i < M; i++) 13 { 14 for (j = 0; j < M - i-1; j++) 15 if (a[j] > a[j+1]) 16 { 17 tmp = a[j]; 18 a[j] = a[j+1]; 19 a[j+1] = tmp; 20 } 21 } 22 for (i = 0; i < M; i++) 23 printf("%d", a[i]); 24 }