Guest User

Untitled

a guest
Oct 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. package linear_search;
  2.  
  3. public class LinearSearch {
  4. public static void main(String[] args) {
  5.  
  6. int[] arr = new int[] {5,1,8,96,1,8,2,8,4,6,3,8,1,6,8,6,1,6,4};
  7.  
  8. linear(arr, 97);
  9. }
  10.  
  11. public static void linear(int[] arr, int targetValue) {
  12.  
  13. for (int i=0; i < arr.length; i++) {
  14. if (arr[i] == targetValue) {
  15. System.out.println(targetValue + "을 찾았습니다");
  16. }
  17. }
  18. System.out.println("값이 존재하지 않습니다.");
  19. }
  20. }
Add Comment
Please, Sign In to add comment