正在加载图片...
弗原創IT教育中心 /*冒泡法排序* for(i=0; I<NUM-1; i++) 兴for(j=NUM-1;j>j)/*内循环:进行每趟比较 if(data l]sdatalj-1 temp=data11 datal]=data j-1] datali-1=temp; /*输出排序后的数据* printf( \nthe result of sort: \n) for(i=0; i<NUM; 1++) printf(%/od",datai) 程序运行(8)/*冒泡法排序*/ for(i=0; i<NUM for(i=0; i<NUM-1; i++) 1; i++) for(j=NUM for(j=NUM-1; j>i; j 1; j>i; j--) /*内循环:进行每趟比较 内循环:进行每趟比较 */ if(data[j]<data[j if(data[j]<data[j-1]) {temp=data[j]; {temp=data[j]; data[j]=data[j data[j]=data[j-1]; data[j-1]=temp; 1]=temp; } /*输出排序后的数据 输出排序后的数据*/ printf(" printf("\nthe result of sort: result of sort:\n"); for(i=0; i<NUM; i++) for(i=0; i<NUM; i++) printf("%d printf("%d ",data[i]); } 程序运行(8)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有