#include<iostream>
using namespace std;
void test(int* arr, int length)
{
for (int i = 0; i < length - 1; i++)
{
for (int j = 0; j < length - i - 1; j++)
{
if (arr[j] > arr[j+ 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
void printf(int* arr, int length)
{
cout << "升序后的数组为:" << endl;
for (int i = 0; i < length; i++)
{
cout << arr[i] << endl;
}
}
int main()
{
int arr[] = { 2,4,6,7,5,1,8,3 };
int a = 8;
test(arr,a);
printf(arr, a);
system("pause");
return 0;
}