#include<stdio.h>
int main()
{
double arr[] = { 1.1,3.4,2.5,6.5 };
int len = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i < len-1; i++)
{
for (int j = 0; j < len-i-1; j++)
{
if (arr[j] > arr[j+1])
{
double temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for (int i = 0; i < len; i++)
{
printf("%.2lf ", arr[i]);
}
return 0;
}
运行结果
因篇幅问题不能全部显示,请点此查看更多更全内容