Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ejercicio7;
- import java.util.*;
- public class Ejercicio7 {
- public static void main(String[] args) {
- Scanner sc= new Scanner (System.in);
- int [] vector= new int[11];
- int num, medio, max, min, j, k;
- j=10;
- k=0;
- for (int i = 0; i < vector.length ; i++) {
- System.out.println("Introduzca dato de vector");
- vector[i]=sc.nextInt();
- }
- System.out.println("Que numero quiere buscar ");
- num=sc.nextInt();
- min=vector[k];
- max=vector[j];
- medio=vector[(j+k)/2];
- while(max>min){
- if(num<max){
- max--;
- }else if(num>min){
- min++;
- }
- }if(max==num||min==num){
- System.out.println("El valor esta en la lista");
- }else{
- System.out.println("El valor no esta en la lista");
- }
- }
- }
Add Comment
Please, Sign In to add comment