编辑代码

#include <stdio.h>
#include <stdlib.h>
int main () {
    int ctr,inner,outer,didSwap,temp;
    int nums[10];

    for (ctr=0;ctr<10;ctr++)
    {
        nums[ctr]=(rand()%99)+1;
    }
    
    puts("\nHere is the list before it is sorted:");
    for (ctr=0;ctr<10;ctr++)
    {
        printf("%d\n",nums[ctr]);
    }

    for (outer=0;outer<9;outer++)
    {
        didSwap=0;
        for (inner=outer;inner<10;inner++)
        {
            if (nums[inner]<nums[outer])
            {
                temp=nums[inner];
                nums[inner]=nums[outer];
                nums[outer]=temp;
                didSwap=1;
            }
        } 
        if (didSwap==0)
        {break;}
    }

    printf("\nHere is the list after the sort:\n");
    for (ctr=0;ctr<10;ctr++)
    { printf("%d\n",nums[ctr]); }
    
	return 0;
}