/*
冒泡排序
function bubblesort (A : list[1..n])
{
var int i, j;
for i from n downto 1
{
for j from 0 to i-1
{
if (A[j] > A[j+1])
{
swap(A[j], A[j+1])
}
}
}
}
*/
#include <iostream>
using namespace std;
//输入数据
void Input(int[], int);
//输出数据
void Output(int[], int);
//冒泡排序
void BubbleSort(int[], int);
int main(void)
{
int *iArray;
int n;
while (cin >> n)
{
iArray = new int[n];
Input(iArray, n);
BubbleSort(iArray, n);
Output(iArray, n);
cout << endl;
}
delete iArray;
return 0;
}
//输入数据
void Input(int iArray[], int length)
{
for (int i = 0; i < length; ++i)
{
cin >> iArray[i];
}
}
//输出数据
void Output(int iArray[], int length)
{
for (int i = 0; i < length; ++i)
{
cout << iArray[i] << " ";
}
}
//冒泡排序
void BubbleSort(int iArray[], int length)
{
for (int i = 1; i < length ; ++i)
{
for (int j = length - 1; j >= i; --j)
{
if (iArray[j] < iArray[j - 1])
{
swap(iArray[j], iArray[j - 1]);
}
}
}
}
冒泡排序
function bubblesort (A : list[1..n])
{
var int i, j;
for i from n downto 1
{
for j from 0 to i-1
{
if (A[j] > A[j+1])
{
swap(A[j], A[j+1])
}
}
}
}
*/
#include <iostream>
using namespace std;
//输入数据
void Input(int[], int);
//输出数据
void Output(int[], int);
//冒泡排序
void BubbleSort(int[], int);
int main(void)
{
int *iArray;
int n;
while (cin >> n)
{
iArray = new int[n];
Input(iArray, n);
BubbleSort(iArray, n);
Output(iArray, n);
cout << endl;
}
delete iArray;
return 0;
}
//输入数据
void Input(int iArray[], int length)
{
for (int i = 0; i < length; ++i)
{
cin >> iArray[i];
}
}
//输出数据
void Output(int iArray[], int length)
{
for (int i = 0; i < length; ++i)
{
cout << iArray[i] << " ";
}
}
//冒泡排序
void BubbleSort(int iArray[], int length)
{
for (int i = 1; i < length ; ++i)
{
for (int j = length - 1; j >= i; --j)
{
if (iArray[j] < iArray[j - 1])
{
swap(iArray[j], iArray[j - 1]);
}
}
}
}