-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberCheck.java
More file actions
37 lines (27 loc) · 827 Bytes
/
Copy pathNumberCheck.java
File metadata and controls
37 lines (27 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] list = {15, 12, 788, 1, -1, -778, 2, 0};
Scanner scan = new Scanner(System.in);
Arrays.sort(list);
System.out.println("Liste: " + Arrays.toString(list));
System.out.print("Girilen sayi: ");
int x = scan.nextInt();
int min = list[0];
int max = list[7];
for (int i : list){
if (i < x){
min = i;
}
}
for (int a : list){
if (a > x){
max = a;
break;
}
}
System.out.println("Girilen sayidan kucuk en yakin sayi: "+min);
System.out.println("Girilen sayidan buyuk en yakin sayi: "+max);
}
}