#include <stdio.h> #define N 5 void main() { int a[N]; int i,j,temp; printf("請輸入待排序的數據: \n"); for (i=0;i<N;i++) scanf("%d",&a[i]); for (i=1;i<=N-1;i++) for (j=0;j<N-i;j++) if (a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } printf("排序后的數據: \n"); for(i=0;i<N;i++) printf("%d",a[i]); printf("\n"); }