-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram43.java
More file actions
42 lines (34 loc) · 1.05 KB
/
Program43.java
File metadata and controls
42 lines (34 loc) · 1.05 KB
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
38
39
40
41
42
// Progran 43
// week 3 Day 2
// Input format:
// - The first line of the input consist of an integer - numContainers, representing the number of container (N)
// - The next line consists of N space seperated integers - cont1, cont2, ... contN, reprensting container capacity.
// Consistaints
// - 1<=numContainers<=1000
// - 1<=cont1 <=1000
// - 1<=cont2 <=1000
// Sample Input:
// 6
// 199 568 23 29 53 29
// sample Output:
// 568 29
// 199 28
// 53 23
import java.util.*;
public class Program43 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numContainers = sc.nextInt();
int[] containers = new int[numContainers];
for (int i = 0; i < numContainers; i++) {
containers[i] = sc.nextInt();
}
for (int i = 0; i < numContainers; i++) {
for (int j = i + 1; j < numContainers; j++) {
if (containers[i] > containers[j]) {
System.out.println(containers[i] + " " + containers[j]);
}
}
}
}
}