-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax6.java
More file actions
35 lines (32 loc) · 831 Bytes
/
MinMax6.java
File metadata and controls
35 lines (32 loc) · 831 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
package minmax;
import java.util.Scanner;
public class MinMax6 {
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 < min))
{
min = r;
minnum = i;
}
if ((i == 1) || (r >= max))
{
max = r;
maxnum = i;
}
}
System.out.println("Birinchi uchragan Eng kichik :"+minnum+" tartib raqamda joylashgan");
System.out.println("Oxirgi uchragan Eng Katta :"+maxnum+"tartib raqamda joylashgan");
}
}