C语言实现冒泡排序
2019-11-23 17:19 hanweiyan 阅读(141) 评论(0) 收藏 举报#include<stdio.h> int main(){ int i,j,temp,a[10]; printf("please input 10 numbers:"); for(i=0;i<10;i++) { scanf("%d",&a[i]); } printf("\n"); for(i=0;i<9;i++) for(j=0;j<9-i;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } printf("the sorted numbers:\n"); for(j=0;j<10;j++) { printf("%d ",a[j]); } printf("\n"); return 0; }
浙公网安备 33010602011771号