[問題] 矩陣翻轉的問題
ACM的練習題
輸入說明 :
第一行會有兩個數字,分別為 列(row)<100 和 行(column)<100,緊接著就是這個矩陣的
內容
輸出說明 :
直接輸出翻轉後的矩陣
我的答案 :
//a015: 矩陣的翻轉
import java.util.Scanner;
public class a015 {
public static void main(String[] args) {
Scanner sin = new Scanner(System.in);
int a,b;
a = sin.nextInt();
b = sin.nextInt();
int number[][] = new int[a][b];
for(int row =0;row<a;row++){
for(int commun=0;commun<b;commun++){
number[row][commun] = sin.nextInt();
}
}
for(int commun=0;commun<b;commun++){
for(int row=0;row<a;row++){
System.out.print(number[row][commun]+ " ");
}
System.out.println();
}
}
}
想法是直接將他的行跟列數字顛倒就好,不過跑到RE
不知道為什麼會這樣@@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.83.163.233
→
03/05 11:34, , 1F
03/05 11:34, 1F
→
03/05 11:42, , 2F
03/05 11:42, 2F
→
03/05 12:22, , 3F
03/05 12:22, 3F
→
03/05 19:10, , 4F
03/05 19:10, 4F
討論串 (同標題文章)