online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/* ALGORITMO PER LA RICERCA BINARIA (detta anche DICOTOMICA) - versione RICORSIVA www.ticoprof.wordpress.com */ #include <iostream> using namespace std; int ricercaBinaria(int array[],int estInf,int estSup,int x) { if(estInf>estSup) {return -1;} int posizioneMedia=(estInf+estSup)/2; if(array[posizioneMedia]==x) {return posizioneMedia;} else { if(array[posizioneMedia]>x) {return ricercaBinaria(array,estInf,posizioneMedia-1,x);} else {return ricercaBinaria(array,posizioneMedia+1,estSup,x);} } } int main() { int a[8]={0,1,2,3,4,6,7,8}; cout<<"quale valore vuoi cercare "; int n; cin>>n; int posizione=ricercaBinaria(a,0,7,n); if(posizione==-1) {cout<<"l'elemento cercato non è presente";} else {cout<<"l'elemento cercato e' presente in posizione "<<posizione;} }

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