-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.8-Load balancing.java
More file actions
31 lines (28 loc) · 916 Bytes
/
3.8-Load balancing.java
File metadata and controls
31 lines (28 loc) · 916 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
import java.util.ArrayList;
import java.util.Scanner;
public class Teianu {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int lines=sc.nextInt();
int packages = sc.nextInt();
ArrayList<ArrayList> al = new ArrayList<>();
for(int i=0;i<lines;i++){
al.add(new ArrayList<Integer>());
}
int rest = packages % lines;
int[][] matrice;
for(int i=0;i<packages;i++){
int t=i%lines;
al.get(t).add(sc.nextInt());
}
StringBuilder sb = new StringBuilder();
for(int i=0;i<al.size();i++){
for(int j=0;j<al.get(i).size();j++){
sb.append(al.get(i).get(j)).append(" ");
}
System.out.println(sb.toString().trim());
sb.setLength(0);
}
}
}