-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiziMinMax.java
More file actions
37 lines (28 loc) · 930 Bytes
/
Copy pathDiziMinMax.java
File metadata and controls
37 lines (28 loc) · 930 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
import java.util.Scanner;
public class DiziMinMax {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Kac adet sayi gireceksiniz? ");
int n = scanner.nextInt();
if (n <= 0) {
System.out.println("Eleman sayisi pozitif olmali.");
return;
}
System.out.print("1. sayiyi girin: ");
int sayi = scanner.nextInt();
int enBuyuk = sayi;
int enKucuk = sayi;
for (int i = 2; i <= n; i++) {
System.out.print(i + ". sayiyi girin: ");
sayi = scanner.nextInt();
if (sayi > enBuyuk) {
enBuyuk = sayi;
}
if (sayi < enKucuk) {
enKucuk = sayi;
}
}
System.out.println("En buyuk sayi: " + enBuyuk);
System.out.println("En kucuk sayi: " + enKucuk);
}
}