#include <stdio.h> void change(int a[],int n){ int i,j,k,x; for(j=0;j<n;j++){ k=0; for(i=0;i<n-j-1;i++){ if(a[i]>a[i+1]){ x=a[i]; a[i]=a[i+1]; a[i+1]=x; } } } } int main(){ int i; int a[]={12,0,25,36,99,85,64,26,77,39,19,99}; change(a,12); for(i=0;i<12;i++) printf("%d\t",a[i]); return 0; }
输出结果:
Output: 0 12 19 25 26 36 39 64 77 85 99 99
时间: 2024-12-27 07:59:41