Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 441 Bytes

冒泡排序.md

File metadata and controls

26 lines (18 loc) · 441 Bytes

冒泡排序

 int a[10] = {3,2,1,4,5,0,6,7,8,9};
    
    int temp = 0;

    for (int i = 0; i < 10 -1; i++) {
        
        for (int j = 0; j < 10 - i - 1; j++) {
            
            if (a[j] > a[j+1]) {
                
                temp = a[j+1];
                a[j+1] = a[j];
                a[j] = temp;
            }
        }
    }
    
    for (int i = 0; i < 10; i++)
    {
        printf("%i",a[i]);
    }