java关于一个类中方法返回数组 20
1个回答
展开全部
public class xiti5_5 {
public static void Printf(int a[][]) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
System.out.print(a[i][j] + " ");
}
System.out.println();
}
}
public static int[][] FangFa(int a[][]) {
int b[][] = new int[a[0].length][a.length];
for (int i = 0; i < a[0].length; i++) {
for (int j = 0; j < a.length; j++)
b[i][j] = a[j][i];
}
return b;
}
public static void main(String args[]) {
int a[][] = { { 1, 2, 3 }, { 4, 5, 6 } };
Printf(a);
Printf(FangFa(a));
}
}
public static void Printf(int a[][]) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
System.out.print(a[i][j] + " ");
}
System.out.println();
}
}
public static int[][] FangFa(int a[][]) {
int b[][] = new int[a[0].length][a.length];
for (int i = 0; i < a[0].length; i++) {
for (int j = 0; j < a.length; j++)
b[i][j] = a[j][i];
}
return b;
}
public static void main(String args[]) {
int a[][] = { { 1, 2, 3 }, { 4, 5, 6 } };
Printf(a);
Printf(FangFa(a));
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询