- /* 第一行會有兩個數字,分別為 列(row)<100 和 行(column)<100,緊接著就是這個矩陣的內容
- 直接輸出翻轉後的矩陣 */
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main(void){
- int row, col;
-
- while (cin >> row >> col){
- int a[row][col];
- int b[col][row];
- for (int i = 0; i < row; i++){
- for (int j = 0; j < col; j++){
- cin >> a[i][j];
- }
- }
- for (int i = 0; i < row; i++){
- for (int j = 0; j < col; j++){
- b[j][i] = a[i][j];
- }
- }
- for (int i = 0; i < col; i++){
- for (int j = 0; j < row; j++){
- cout << b[i][j] << " ";
- }
- cout << endl;
- }
- }
-
- //system("pause");
- return 0;
-
- }
複製代碼 回復 2# b1081081 |