-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax12.java
More file actions
23 lines (21 loc) · 730 Bytes
/
MinMax12.java
File metadata and controls
23 lines (21 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package minmax;
import java.util.Scanner;
public class MinMax12 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// int n = 8; // -10 2 9 1 -3 6 10 -11
System.out.print("n = ");
int n = scanner.nextInt(); // -10 -2 -9 -1 -3 -6 -10 -11
int number, min = Integer.MAX_VALUE;
boolean topildi = false; // musbat topilsa true bo'ladi
for (int i = 1; i <= n; i++) {
number = scanner.nextInt();
if (number > 0) { // musbat
if (min > number) min = number;
topildi = true;
}
}
if (topildi) System.out.println(min);
else System.out.println(0);
}
}