#include <iostream>

struct FParams
{
    int* inputArray;
    int length;
    int passStartIndex;
    int currentIndex;
};

void bubbleSort(FParams* fp)
{
    if (fp->passStartIndex == fp->length - 1) return;
    if (fp->currentIndex == fp->length - 1)
    {
        fp->passStartIndex++;
        fp->currentIndex = 0;
        return bubbleSort(fp);
    }

    //compare items at current index and current index + 1 and swap if required
    if(fp->inputArray[fp->currentIndex] > fp->inputArray[fp->currentIndex + 1])
    {
        int temp = fp->inputArray[fp->currentIndex + 1];
        fp->inputArray[fp->currentIndex + 1] = fp->inputArray[fp->currentIndex];
        fp->inputArray[fp->currentIndex] = temp;
    }

    fp->currentIndex++;
    return bubbleSort(fp);
}

int main()
{
    FParams fp;
    fp.length = 200;
    fp.inputArray = new int[fp.length];
    fp.passStartIndex = 0;
    fp.currentIndex = 0;

    // create array that is sorted in descending order:
    for (int i = 0; i < fp.length; ++i)
        fp.inputArray[i] = fp.length - i;

    // bubble sort recursion:
    bubbleSort(&fp);

    // print sorted array:
    for (int i = 0; i < fp.length; ++i)
        std::cout << fp.inputArray[i] << ' ';

    delete[] fp.inputArray;
}
