数组转置

/*
题目:数组转置
内容:


编写程序将2行3列的数组行列置换复制给3行2列的数组(即数组的转置)。已经写了如下代码,请完善之:

class y{
public static void main(String[] args) throws Exception {
int a[][]={{1,2,3},{4,5,6}};
int b[][]=new int[3][2];
for(int i=0;i<2;i++){
for(int j=0;j<3;j++){
_____________________;
}
}
}
}
*/

 1 class  pro21{
 2     public static void main(String[] args) throws Exception {
 3         int a[][]={{1,2,3},{4,5,6}};
 4         int b[][]=new int[3][2];
 5         for(int i=0;i<2;i++){
 6             for(int j=0;j<3;j++){
 7                 b[j][i] = a[i][j];
 8             }    
 9         }            
10     }
11 }

 


/*
  又遇到一个简单题了,又松了一口气,,,,
*/

posted on 2013-05-04 10:46  wsxjbcy  阅读(210)  评论(0编辑  收藏  举报

导航