标签:bsp har for style enter put ali pre clu
冒泡
paopao.c
1 #include <stdio.h> 2 3 int main(void) 4 { 5 int a[] = {8,5,1,6,9}; 6 int i,j,n,temp; 7 8 n = sizeof(a)/sizeof(a[0]); 9 10 for(i=0;i<n-1;++i){ 11 for(j=0;j<n-1-i;++j){ 12 if(a[j]<a[j+1]){ 13 temp = a[j]; 14 a[j] = a[j+1]; 15 a[j+1]= temp; 16 } 17 } 18 } 19 20 for(i=0;i<n;i++) 21 printf("%d ",a[i]); 22 putchar(10); 23 24 return 0 ; 25 }
测试:
标签:bsp har for style enter put ali pre clu
原文地址:https://www.cnblogs.com/panda-w/p/11080183.html