#include <iostream>
using namespace std;
void Sort(int ar[], int n)
{
for(int i = 0; i < n-1; ++i)
{
for(int j = 0; j < n-i-1; ++j)
{
if(ar[j] < ar[j+1])
{
int tmp = ar[j];
ar[j] = ar[j+1];
ar[j+1] = tmp;
}
}
}
}
void main()
{
int ar[] = {2,86,0,80,45,35,678,34,23,1256,78};
int n = sizeof(ar) / sizeof(int);
Sort(ar,n);
for(int j = 0; j < n; ++j)
{
cout << ar[j] << " ";
}
cout << endl;
}
数组排序
最新推荐文章于 2024-12-04 14:01:37 发布