### Problem, Vector/Array

Hello, againg, thanks for the help in my other topic, but now, i need again xD.

in this program what i'm doing is to search for a number when the vector is in order, and count how many times that number appears, the problem is that count how many times the number does not appear, but when its appear the program stays in an "standby mode" and the cursor does not move.

 ``123456789101112131415161718192021222324252627282930313233343536`` `````` int buscarNumOrdenado (int x [MAX]) //MAX is the define { int num,d, LimiteInferior, LimiteSuperior,mitad; d=0; LimiteInferior = 0; LimiteSuperior = MAX-1; cout<<"Favor de escribir el numero que desea buscar ->"; cin>>num; while(LimiteInferior <= LimiteSuperior){ mitad = (LimiteSuperior + LimiteInferior)/2; if (num == x[mitad]){ d++; } else if(num >x[mitad]) LimiteInferior = mitad +1; else LimiteSuperior = mitad-1; } cout<<"El numero "<

Last edited on
Suppose that you find the number. This is what would execute
 ``1234`` ``````while( LimiteInferior <= LimiteSuperior ){ mitad = (LimiteSuperior + LimiteInferior)/2; d++; }``````
¿see the infinite loop?
Yes, thanks for the help and im sorry for the late response, prob solved
Topic archived. No new replies allowed.