Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.print("Введите размер массива X: ");
- int n = in.nextInt();
- System.out.print("Введите нижнюю границу инервала A: ");
- int a = in.nextInt();
- System.out.print("Введите верхнюю границу интервала B: ");
- int b = in.nextInt();
- int[] x = new int[n];
- int count = 0, res = 0;
- for (int i = 0; i < n; i++) {
- System.out.print("Введите x[" + i + "]: ");
- x[i] = in.nextInt();
- if (x[i] >= a && x[i] <= b)
- count++;
- if (count == 2)
- res = x[i];
- }
- System.out.println("Второй элемент, значение которого попадает в интервал [A;B]: " + res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement