-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind.java
29 lines (26 loc) · 832 Bytes
/
Find.java
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
import java.util.*;
class Find{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a[] = new int[n];
int inofs = 0 , inofl = 0;
for(int i=0;i<n;i++){
System.out.println("Enter array of "+i);
a[i] = sc.nextInt();
}
int small = a[0];
int large = a[0];
for(int j=0;j<n;j++){
if(a[j]>large){
large = a[j];
inofl = j;
}
if(a[j]<small){
small = a[j];
inofl = j;
}
}
System.out.println("Largest is "+large+"these index is"+inofs+" Smallest is "+small+"these index is"+inofl);
}
}