a015.
矩陣的翻轉
| From: [1.172.230.240] |
發表日期
:
2013-10-02 21:14
import java.util.Scanner;
public class a015 {
public static void main (String[] args) {
Scanner cin = new Scanner(System.in);
int rowa = cin.nextInt(); // 列
int rowb = rowa;
int column = cin.nextInt(); // 行
int arr[][];
arr = new int[rowa][column];
int j = 0;
while (rowa > 0 && rowa < 100 && column < 100) { //放入陣列
for ( int i = 0; i < column; i++) {
arr[j][i] = cin.nextInt();
}
j++;
rowa--;
}
for (int i = 0; i < column; i++) { // 翻轉&輸出
for (int k = 0; k < rowb; k++) {
System.out.print(arr[k][i] + " ");
}
if ( i < (column-1) ) {
System.out.print("\n");
}
}
}
}
不知到哪邊錯誤了... 我輸出的內容跟題目一樣... 懇請大大替我解答。