[英]How to convert 5 1D arrays to a 2D array
So i have to create a bingo board which i have done so, don't mind the long code it's repetitive for the first column method. 因此,我必须创建一个这样做的宾果板,不要介意长代码对于第一列方法而言是重复的。 So i wanna convert these 5 1D arrays to 1 2D array so i can check for a bingo. 所以我想将这5个1D数组转换为1个2D数组,以便我可以检查宾果游戏。 Could someone explain to me in detail how i would convert these 5 arrays to 1 2D array, or if it's possible to check 5 1D arrays. 有人可以详细向我解释我如何将这5个数组转换为1个2D数组,或者是否有可能检查5个1D数组。
package bingo;
import static java.rmi.Naming.list;
import java.util.ArrayList;
import java.util.Collections;
import static java.util.Collections.list;
import java.util.List;
public class Bingo {
public static void main(String[] args) {
int[][] card1 = new int[5][5];
int[] column1 = new int[5];
int[] column2 = new int[5];
int[] column3 = new int[5];
int[] column4 = new int[5];
int[] column5 = new int[5];
column1(column1);
System.out.println("");
column2(column2);
System.out.println("");
column3(column3);
System.out.println("");
column4(column4);
System.out.println("");
column5(column5);
System.out.println("");
cardofzeros(card1);
for (int i = 0; i < card1.length; i++) {
for (int j = 0; i < card1.length; i++) {
}
}
}
public static void column1(int[] column1) {
int[] colm = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
List l = new ArrayList();
for (int i : colm) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column2(int[] column2) {
int[] colm2 = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
List l = new ArrayList();
for (int i : colm2) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column3(int[] column3) {
int[] colm3 = {31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
List l = new ArrayList();
for (int i : colm3) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column4(int[] column4) {
int[] colm4 = {46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60};
List l = new ArrayList();
for (int i : colm4) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void column5(int[] column5) {
int[] colm2 = {61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75};
List l = new ArrayList();
for (int i : colm2) {
l.add(i);
}
Collections.shuffle(l);
for (int i = 0; i < 5; i++) {
System.out.print("|" + l.get(i));
}
}
public static void cardofzeros(int[][] card1) {
for (int i = 0; i < 5; i++) {
for (int j = 0; i < 5; i++) {
card1[i][j]=0;
System.out.print("|"+card1[i][j]);
}
}
}
}
int[] first = null;
int[] second = null;
int[] third = null;
int[] fourth = null;
int[] fifth = null;
int[][] arr2d = new int[][]{first , second , third , fourth , fifth};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.