#include <iostream>
using namespace std;
void print(int *p , int len)
{
for (int i = 0; i < len; ++i)
{
cout << p[i] << ' ';
}
cout << endl;
}
void swap(int &a , int &b)
{
int temp = a;
a = b;
b = temp;
}
void sort(int *p , int len)
{
int i,j,temp;
for(i = 1; i < len ; i++)
{
temp = p[i];
for(j = i-1 ;j >= 0 ; j--)
{
if (temp > p[j])
{
p[j+1] = p[j];
}
else
break;
}
p[j+1] = temp;
}
}
int main()
{
int a[] = {2,35,76,23,876,74,12,7};
int len = sizeof(a)/sizeof(a[0]);
print(a,len);
sort(a,len);
print(a,len);
return 0;
}