Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6dbd574

Browse files
author
Hud
committed
GITA MASALA
1 parent bf943d5 commit 6dbd574

24 files changed

+521
-5
lines changed
Binary file not shown.
-469 Bytes
Binary file not shown.
582 Bytes
Binary file not shown.

‎src/MinMax.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import java.util.Scanner;
2+
3+
public class MinMax {
4+
public static void main(String[] args) {
5+
Scanner scanner = new Scanner(System.in);
6+
int i;
7+
int n;
8+
int r;
9+
int min = 0;
10+
int minnum=0;
11+
// 3 5 2 4 1
12+
System.out.println("N:");
13+
n= scanner.nextInt();
14+
//
15+
for (i = 1; i <= n; ++i) {
16+
System.out.print(i+"-");
17+
r= scanner.nextInt();
18+
//
19+
if ((r < min) || (i == 1)) {
20+
min = r;
21+
minnum = i-1;
22+
}
23+
}
24+
System.out.println("Minimum:"+minnum);
25+
}
26+
}

‎src/minmax/MinMax1.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package minmax;
2+
3+
import java.util.Scanner;
4+
5+
public class MinMax1 {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
int n, min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
9+
System.out.print("n = ");
10+
n = scanner.nextInt();
11+
12+
13+
for (int i = 1; i <= n; i++) {
14+
System.out.print(i + " = ");
15+
int number = scanner.nextInt(); // i=1
16+
if (min > number) min = number; // min = 5
17+
if (max < number) max = number; // max = 5
18+
}
19+
20+
System.out.println(max);
21+
System.out.println(min);
22+
}
23+
}

‎src/minmax/MinMax10.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package minmax;
2+
3+
import java.util.Scanner;
4+
5+
public class MinMax10 {
6+
public static void main(String[] args) {
7+
int n;
8+
int r;
9+
int min = Integer.MAX_VALUE;
10+
int max = Integer.MIN_VALUE;
11+
int minnum = 0;
12+
int maxnum = 0;
13+
Scanner scanner = new Scanner(System.in);
14+
System.out.println("N:");
15+
n = scanner.nextInt();
16+
for (int i = 1; i <= n; ++i) {
17+
System.out.print(i + ".");
18+
r = scanner.nextInt();
19+
if ((i == 1) || (r < min)) {
20+
min = r;
21+
minnum = i;
22+
}
23+
if ((i == 1) || (r > max)) {
24+
max = r;
25+
maxnum = i;
26+
}
27+
}
28+
29+
System.out.printf("Birinchi uchragan ekstremal: %d\n", Math.min(minnum, maxnum));
30+
31+
}
32+
}

‎src/minmax/MinMax11.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package minmax;
2+
3+
import java.util.Scanner;
4+
5+
public class MinMax11 {
6+
public static void main(String[] args) {
7+
int n;
8+
int r;
9+
int min = Integer.MAX_VALUE;
10+
int max = Integer.MIN_VALUE;
11+
int minnum = 0;
12+
int maxnum = 0;
13+
Scanner scanner = new Scanner(System.in);
14+
System.out.println("N:");
15+
n = scanner.nextInt();
16+
for (int i = 1; i <= n; ++i) {
17+
System.out.print(i + ".");
18+
r = scanner.nextInt();
19+
if ((i == 1) || (r > max)) {
20+
max = r;
21+
maxnum = i;
22+
}
23+
if ((i == 1) || (r <= min)) {
24+
min = r;
25+
minnum = i;
26+
}
27+
}
28+
29+
System.out.printf("Birinchi uchragan ekstremal: %d\n", Math.max(minnum, maxnum));
30+
31+
32+
}
33+
}

‎src/minmax/MinMax12.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package minmax;
2+
3+
import java.util.Scanner;
4+
5+
public class MinMax12 {
6+
public static void main(String[] args) {
7+
Scanner scanner = new Scanner(System.in);
8+
// int n = 8; // -10 2 9 1 -3 6 10 -11
9+
System.out.print("n = ");
10+
int n = scanner.nextInt(); // -10 -2 -9 -1 -3 -6 -10 -11
11+
int number, min = Integer.MAX_VALUE;
12+
boolean topildi = false; // musbat topilsa true bo'ladi
13+
for (int i = 1; i <= n; i++) {
14+
number = scanner.nextInt();
15+
if (number > 0) { // musbat
16+
if (min > number) min = number;
17+
topildi = true;
18+
}
19+
}
20+
if (topildi) System.out.println(min);
21+
else System.out.println(0);
22+
}
23+
}

‎src/minmax/MinMax13.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package minmax;
2+
3+
import java.util.Scanner;
4+
5+
public class MinMax13 {
6+
public static void main(String[] args) {
7+
int n;
8+
int r;
9+
int max = Integer.MIN_VALUE;
10+
int maxnum = 0;
11+
Scanner scanner = new Scanner(System.in);
12+
System.out.println("N:");
13+
n = scanner.nextInt();
14+
15+
for (int i = 1; i <= n; ++i) {
16+
System.out.print(i+".");
17+
r= scanner.nextInt();
18+
if ((r % 2 != 0 && r > max) || (i == 1)) {
19+
max = r;
20+
maxnum = i;
21+
}else {
22+
maxnum=0;
23+
}
24+
}
25+
System.out.printf(" %d",maxnum);
26+
27+
}
28+
}

‎src/minmax/MinMax14.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package minmax;
2+
3+
import java.util.Scanner;
4+
5+
public class MinMax14 {
6+
public static void main(String[] args) {
7+
int b;
8+
int r;
9+
int min = Integer.MAX_VALUE;
10+
int minnum = 0;
11+
Scanner scanner = new Scanner(System.in);
12+
System.out.println("B:");
13+
b = scanner.nextInt();
14+
15+
for (int i = 1; i <= 10; ++i) {
16+
System.out.print(i+".");
17+
r= scanner.nextInt();
18+
//
19+
if ((r > b) && ((r < min) || (minnum == 0))) {
20+
min = r;
21+
minnum = i;
22+
}else {
23+
minnum= 0;
24+
min=0;
25+
}
26+
}
27+
System.out.printf("%d %d\n", minnum,0);
28+
29+
}
30+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /