C++, Bubble sort, how to change the code to see every step of sort in the output?
Task is: Input In the first line of input, one integer n(1<=n<=1000) is given. The secon line contains n natural numbers - sequence of numbers to be sorted Output You should print k lines, where k is the required number ofiterations through the array to sort the string. The last line ahould be a sorted string. In case the string on the input is sorted, nothing needs to be printed. Example: Input 5 1 2 3 5 4 Output 1 2 3 4 5 Input 5 5 9 3 1 2 Output 5 3 1 2 9 3 1 2 5 9 1 2 3 5 9 Input 5 10 100 1000 10000 100000 Output And code so far: #include <iostream> #include <string> int bubblesort() { int max; std::cin>>max; int *numarray=new int[max]; for(int i = 0; i <max; i++) { std::cin>>numarray[i]; } std::cout<<"\n"; for(int i=1; i<max; i++) { for(int j=0; j<max - i; j++) { if(numarray[j]>numarray[j+1]) { int temp=numarray[j]; numarray[j]=numarray[j+1]; numarray[j+1]=temp; } } for(int k=0; k<max; k++) std::cout<<numarray[k]<<" "; std::cout<<"\n"; } for(int i=0; i<max; i++) { Continued below...........