#include <iostream>
using namespace std;
void insertionsort(int a[])
{
int temp, pass=0;
for (int i = 1; i <10; i++)
{
for (int j = i; j >= 1; j--)
{
if (a[j]<a[j - 1])
{
temp = a[j];
a[j] = a[j - 1];
a[j - 1] = temp;
pass ++;
}
}
}
cout << "After Insertion sort: " << endl;
for (int i = 0; i < 10; i++)
{
cout << a[i] << endl;
}
cout << "Number of passes: " << pass << endl;
}
void selectionsort(int ar[])
{
int temp, pass = 0;
for (int i = 0; i < 10; i++)
{
int min = ar[i];
int loc = i;
for (int j = i + 1; j<10; j++)
{
if (min>ar[j])
{
min = ar[j];
loc = j;
}
}
temp = ar[i];
ar[i] = ar[loc];
ar[loc] = temp;
pass ++;
}
cout << "After Selection sort: " << endl;
for (int i = 0; i < 10; i++)
{
cout << ar[i] << endl;
}
cout << "Number of passes: " << pass << endl;
}
void bubblesort(int arr[])
{
int temp, pass =0;
for (int j = 1; j < 10; j++)
{
for (int i = 0; i< 10-j; i++)
{
if (arr[i]>arr[i + 1])
{
temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
pass ++;
}
}
}
cout << "After Bubble sort: " << endl;
for (int i = 0; i < 10; i++)
{
cout <<arr[i] << endl;
}
cout << "Number of passes: " << pass << endl;
}