You are on page 1of 1

#include <iostream>

#include <stdlib.h>
#include < math.h >
using namespace std;
int main ()
{
int a[5]={7,1,8,2,5};
int sr=0;
int pr=0;
bool h;
for (int i=0;i<5;i++)
cout<<a[i]<<" ";
for (int i=0;i<5;i++)
{
for (int j=0;j<5-1;j++)
{
sr++;
if(a[j]>a[j+1])
{
pr++;
swap(a[j],a[j+1]);
}
}
}

cout<<endl;
cout<<endl;
for (int i=0;i<5;i++)
cout<<a[i]<<" ";
cout<<endl;
cout<<endl;
cout<<"Chislo sravneniy "<<sr<<endl;
cout<<endl;
cout<<"Chislo perestanovok "<<pr<<endl;
cout<<endl;
sr=0;
pr=0;
system ("PAUSE");
return 0;
}