#include
#include
#include
#include
template
void swap(T &a, T&b)
{
T t=a;
a=b;
b=t;
}
void printArray(int *array, int length)
{
for (int i=0;i std::cout<<std::setw(4)<<array[i];<br> std::cout<<std::endl;<br>}
int main()
{
srand(time(0));
int length;
std::cin>>length;
int *array=new int[length];
for (int i=0;i array[i]=rand()%100+1;
printArray(array,length);
int posMax=0;
for (int i=1;i if (array[posMax] posMax=i;
bool flag=false;
while (flag==false)
{
flag=true;
for (int i=posMax+2;i if (array[i] {
flag=false;
swap(array[i],array[i-1]);
}
}
printArray(array,length);
return 0;
}