online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> using namespace std; void quicksort(int a[], int low, int high); int partition(int a[], int low, int high); int main(){ int minIndex=0, maxIndex=9; int n = 10; int myvec[] = {70, 30, 80, 10, 0, 50, 20, 60, 90, 40}; quicksort(myvec, 0, n-1); for (int i=0; i<=n-1; i++){ cout<<myvec[i]<<", "; } cout<<endl; return 0; } void quicksort(int a[], int lowIndex, int highIndex){ if (lowIndex < highIndex){ //particionar desde a[lowIndex] hasta a[highIndex] //y devolver el indice del pivote int pivotIndex = partition(a, lowIndex, highIndex); //recursivamente ordenar las dos partes quicksort(a, lowIndex, pivotIndex-1); quicksort(a, pivotIndex+1, highIndex); } } int partition(int a[], int i, int j){ int pivot = a[i]; // pivot es el pivote // Las sublistas S1, S2, // estan vacias al inicio int pivotIndexAux = i; // pasamos por cada elemento en la // region no particionada for (int k=i+1; k<=j; k++){ if (a[k] < pivot){ pivotIndexAux++; swap(a[k], a[pivotIndexAux]); } else{ // no se hace nada } } // intercambiar el pivote con a[minorIndexAux] swap(a[i], a[pivotIndexAux]); //retornamos el indice del pivote return pivotIndexAux; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue