#include <string>
#include <iostream>
#include <fstream>
usingnamespace std;
string printList(int *list, int numElem)
{
string sortedList = "";
//NOW OUTPUT the sorted list
for ( int k = 0; k < numElem; k++ )
{
sortedList+=list[k];
if ( k != numElem - 1 )//We don't need a comma for last item
sortedList+=" , ";
}
return sortedList;
}
int main()
{
int arraySize = 10;
int insertionList[10] = {10,9,8,7,6,5,4,3,2,1};
insertionSort(insertionList, arraySize);//my own fcn for insertion sort
ofstream myFile;
myFile.open("insertionSorted.txt");
string sortedList = printList(insertionList, arraySize);
for ( int i = 0; i < arraySize; i++ )
{
myFile << sortedList;
}
}