online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
// Búsqueda binaria // Agosto de 2009 Con Clase, Salvador Pozo #include <iostream> using namespace std; int Binaria(int*, int, int, int); int tabla[] = { 1, 3, 12, 33, 42, 43, 44, 45, 54, 55, 61, 63, 72, 73, 82, 83, 84, 85, 94, 95, 101, 103, 112, 133, 142, 143, 144, 145, 154, 155, 161, 163, 172, 173, 182, 183, 184, 185, 194, 195 }; int main() { int pos; int valor=141; pos = Binaria(tabla, valor, 0, sizeof(tabla)/sizeof(tabla[0])-1); if(pos > 0) cout << "Valor " << valor << " encontrado en posicion: " << pos << endl; else cout << "Valor " << valor << " no encontrado" << endl; return 0; } /* Función de búsqueda binaria: Busca el "valor" dentro del vector "vec" entre los márgenes inferior "i" y superior "s" */ int Binaria(int* vec, int valor, int i, int s) { int inferior = i; int superior = s; int central; do { central = inferior+(superior-inferior)/2; if(vec[central] == valor) return central; else if(vec[central] < valor) inferior = central+1; else superior = central-1; } while(superior >= inferior); return -1; }

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