#include<stdio.h> #define N 10 int main() { int s[N] ,i,j,a[N],t,count=0; printf("请为数组元素赋初值:\n"); for (i=0;i<N;i++) scanf("%d",&a[i]); for(i=0;i<N-1;i++) for(j=0;j<N-1;j++) if(a[j]>a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } printf("经过交换后的数组元素为:\n"); for(i=0;i<N;i++) { count++; printf("%d ",a[i]); if(count%5==0) printf ("\n"); } printf("\n"); }
标签:int,元素,1.8,冒泡排序,数组,printf From: https://www.cnblogs.com/xuan-2004/p/17351121.html