Guest User

Untitled

a guest
Dec 10th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.*;
  3. class lsearch
  4. {
  5. public static void main(String arg[])
  6. {
  7. Scanner sc = new Scanner(System.in);
  8. Random randomGenerator = new Random();
  9. int flag=0;
  10. int [] a = new int[10] ;
  11. for (int idx = 0; idx < 10; ++idx)
  12. {
  13. a[idx] = randomGenerator.nextInt(100);
  14. //log("Generated : " + randomInt);
  15. System.out.println("Number :"+a[idx]);
  16. }
  17. System.out.println("Enter number to search:");
  18. int ip = sc.nextInt();
  19. for(int i=0;i<10;i++)
  20. {
  21. if(ip == a[i])
  22. {
  23. System.out.println("Number found");
  24. flag=1;
  25. break;
  26. }
  27. }
  28. if(flag==0)
  29. {System.out.println("Number not found :( ");}
  30.  
  31.  
  32. }
  33. }
Add Comment
Please, Sign In to add comment