JoseLargo

Untitled

Dec 6th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1.  
  2. package ejercicio7;
  3.  
  4. import java.util.*;
  5. public class Ejercicio7 {
  6.  
  7.    
  8.     public static void main(String[] args) {
  9.         Scanner sc= new Scanner (System.in);
  10.         int [] vector= new int[11];
  11.         int num, medio, max, min, j, k;
  12.         j=10;
  13.         k=0;
  14.        
  15.         for (int i = 0; i < vector.length ; i++) {
  16.             System.out.println("Introduzca dato de vector");
  17.             vector[i]=sc.nextInt();
  18.         }
  19.         System.out.println("Que numero quiere buscar ");
  20.         num=sc.nextInt();
  21.         min=vector[k];
  22.         max=vector[j];
  23.         medio=vector[(j+k)/2];
  24.         while(max>min){
  25.             if(num<max){
  26.                 max--;  
  27.             }else if(num>min){
  28.                 min++;
  29.             }
  30.         }if(max==num||min==num){
  31.             System.out.println("El valor esta en la lista");
  32.         }else{
  33.             System.out.println("El valor no esta en la lista");
  34.                 }
  35.     }  
  36. }
Add Comment
Please, Sign In to add comment