online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
// 3a.cpp #include <stdio.h> #include <iostream> #include <fstream> using namespace std; void intercambia(int *array, int pos1, int pos2){ int temp = array[pos2]; array[pos2] = array[pos1]; array[pos1] = temp; } void quickSort(int *array, int ini, int fin){ if( ini >= fin ) return; int i, f, pivote, Temp; // Establecemos los extremos temporales y el pivote. i = ini; f = fin; pivote = array[(ini+fin)/2]; do{ // Buscamos el primer elemento de izquierda a derecha que sea mayor // al pivote. while( array[i] < pivote ) i++; // Buscamos el primer elemento de derecha a izquierda que sea menor // al pivote. while( array[f] > pivote ) f--; if( i <= f ){ // Intercambiamos los extremos. intercambia(array, i, f); // Aumentamos los contadores. i++; f--; } }while(i<f); // Una vez hecha la partición llamamos recursivamente al Quicksort. quickSort(array, ini, f); quickSort(array, i, fin); } int main(){ ofstream salida; ifstream entrada; int n, i; entrada.open("input.txt", ios::in); if( entrada.is_open() ){ entrada>>n; }else{ cout<<"Error al abrir el archivo.."<<endl; return 0; } int *enano, *peso; enano = new int[n]; peso = new int[n]; for(i=0; i<n; i++) entrada>>enano[i]; for(i=0; i<n; i++) entrada>>peso[i]; entrada.close(); quickSort(enano,0,n-1); quickSort(peso,0,n-1); salida.open("output.txt", ios ::out); for(i=0; i<n; i++) salida<<enano[i]<<" "<<peso[i]<<endl; salida.close(); delete[] enano; delete[] peso; return 0; }
5 3 5 8 2 6 6 9 10 3 1
5 3 5 8 2 6 6 9 10 3 1
2 1 3 3 5 6 6 9 8 10

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