-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax7.java
More file actions
37 lines (32 loc) · 941 Bytes
/
MinMax7.java
File metadata and controls
37 lines (32 loc) · 941 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
package minmax;
import java.util.Scanner;
public class MinMax7 {
public static void main(String[] args) {
int n;
int minnum=0;
int maxnum=0;
int r;
int min=Integer.MAX_VALUE;
int max=Integer.MIN_VALUE;
Scanner scanner=new Scanner(System.in);
System.out.println("N:");
n=scanner.nextInt();
for (int i = 1;i <= n;++i)
{
System.out.print(i+"-");
r= scanner.nextInt();
if ((i == 1) || (r > max))
{
max = r;
maxnum = i;
}
if ((i == 1) || (r <= min))
{
min = r;
minnum = i;
}
}
System.out.println("Birinchi uchragan Eng Katta :"+maxnum+"- tartib raqamda joylashgan");
System.out.println("Oxirgi uchragan Eng kichik :"+minnum+"- tartib raqamda joylashgan");
}
}