[C] 纯文本查看 复制代码 int main(int argc, const char * argv[])
{
int arr[6] = {1,23,44,56,78,0};
int len =sizeof(arr)/sizeof(arr[0]);
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len - i -1; j++)
{
if(arr[j]<arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1]=temp;
}
}
}
for (int i = 0; i < len; i++)
{
printf("%d\n",arr[i]);
}
return 0;
} |