Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main11 {
- private static void check(int[] arr, int toCheckValue)
- {
- boolean test = false;
- for (int element : arr) {
- if (element == toCheckValue) {
- test = true;
- break;
- }
- }
- System.out.println("Is " + toCheckValue
- + " present in the array: " + test);
- }
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int N = scan.nextInt();
- int arr[] = new int[N];
- for (int a = 0; a < N; a++) {
- arr[a] = scan.nextInt();
- }
- int toCheckValue = scan.nextInt();
- check(arr, toCheckValue);
- }
- }
Add Comment
Please, Sign In to add comment