#include <iostream>
using namespace std;
int main()
{
int count = 1;
int array[]={1,2,4,3,5,6,8,7,9,11,10,12,13};
int size;
size = sizeof array/sizeof array[0];
for (int i = 0; i < size-1; i++) // for loop to find how many sorted runs
{
if (array[i] > array[i+1])
count++;
}
cout<<"sorted runs is "<<count<<endl;
int pst = 0; //initialization of position for the start of every runs
int* pos= new int[size]; //creating new array to store the value of new sorted runs position
for (int j = 0; j < size; j++) //loop to find position for the start of sorted runs and store it in pos array
{
if (array[j] > array[j+1])
pos[pst] = j+1;
pst++;
}
cout<<"sorted runs start at index "<< pos[0]<<endl; //printing the first sorted runs,which is index 0
for (int k = 0; k < size; k++) //loop to print the rest sorted runs position
{
if (array[k] > array[k+1])
{
cout<<"sorted runs start at index "<< pos[k]<<endl;
}
}
return 0;
}