【每日一练】一维数组转为二维数组


  String[] s = {"A","B","C"};
 String[] ss = {"X","Y","Z"};
 两个一维数组转换一个二维数组?
 String[][] sss = {{"A","X"},{"A","Y"},{"A","Z"},{"B","X"},{"B","Y"},{"B","Z"},{"C","X"},{"C","Y"},{"C","Z"}};
 
===================

 

--来自网页客户端
已邀请:

郑远翔做厂工

赞同来自:

int[][] erwei(int[]s,int[]ss){
int[][] a=new int[s.length][2];
for(int i=0,i<s.length;i++){
a[i][0]=s[i];
a[i][1]=ss[i];
}
return a;
}

--来自移动客户端

郑远翔做厂工

赞同来自:

郑远翔嫖娼,郑远翔嫖娼
public class Main
{
public static void main(String[] args)
{
new Main();
}
Main()
{
测试获取cpu数量();
}

private void 测试获取cpu数量()
{

int[] a1={2,9,3};
int[] a2={3,10,4};
int [][]d=erwei(a1,a2);
for(int i=0;i<d.length;i++){
sc(d[i][0]+" "+d[i][1]);

}
}
int[][] erwei(int[]s,int[]ss){
int[][] a=new int[s.length][2];
for(int i=0;i<s.length;i++){
a[i][0]=s[i];
a[i][1]=ss[i];
}
return a;
}
void sc(Object object)
{
System.out.println(object);
}
}

--来自移动客户端

要回复问题请先登录注册

Template error, template file not found