Академический Документы
Профессиональный Документы
Культура Документы
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Semana1
{
class tarea1
{
private int[] v1;
private int a;
{
int b1,ma;
int mi = 0, r=0;
ma = a;
bool enc = false;
Console.WriteLine("Valor a buscar:");
b1 = Convert.ToInt32(Console.ReadLine());
while (mi <= ma && enc == false)
{
r = (mi + ma) / 2;
if (v1[r] == b1)
enc = true;
if (v1[r] > b1)
ma = r - 1;
else
mi = r + 1;
}
if (enc == false)
{
Console.WriteLine("El valor {0} no fue encontrada", b1);
}
else
{
Console.WriteLine("El valor {0} esta en la posicion: {1}", b1, r + 1);
}
Console.ReadKey();
}
t1.busv1();
break;
default:
break;
}
}
while (opc2 < 5);
Console.Clear();
Console.Write("Desea dar otro vector:\n\t1.-Si\n\t2.-No\n\t");
opc1 = Convert.ToInt32(Console.ReadLine());
}
while (opc1 < 2);
}
}
}