-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxMin.java
More file actions
33 lines (28 loc) · 842 Bytes
/
MaxMin.java
File metadata and controls
33 lines (28 loc) · 842 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
import java.util.*;
public class MaxMin {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int i,j;
int eb=0;
System.out.println("Kaç elemanlı bir dizi olacak?");
int n=scn.nextInt();
int []dizi=new int[n];
for(i=0;i<n;i++){
System.out.println("Dizinin "+(i+1)+"."+"sayısını giriniz");
dizi[i]=scn.nextInt();
}
for(i=0;i<n;i++){
if(dizi[i]>eb){
eb=dizi[i];
}
}
System.out.println("Dizinin En Büyük elemanı :"+eb);
int ek=eb;
for(i=0;i<n;i++){
if(dizi[i]<ek){
ek=dizi[i];
}
}
System.out.println("Dizinin En Küçük elemanı: "+ek);
}
}