Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package linear_search;
- public class LinearSearch {
- public static void main(String[] args) {
- int[] arr = new int[] {5,1,8,96,1,8,2,8,4,6,3,8,1,6,8,6,1,6,4};
- linear(arr, 97);
- }
- public static void linear(int[] arr, int targetValue) {
- for (int i=0; i < arr.length; i++) {
- if (arr[i] == targetValue) {
- System.out.println(targetValue + "을 찾았습니다");
- }
- }
- System.out.println("값이 존재하지 않습니다.");
- }
- }
Add Comment
Please, Sign In to add comment