返回列表 發帖
  1. /* 第一行會有兩個數字,分別為 列(row)<100 和 行(column)<100,緊接著就是這個矩陣的內容
  2.    直接輸出翻轉後的矩陣 */
  3. #include <iostream>
  4. #include <cstdlib>
  5. using namespace std;
  6. int main(void){
  7.     int row, col;
  8.    
  9.     while (cin >> row >> col){
  10.           int a[row][col];
  11.           int b[col][row];
  12.           for (int i = 0; i < row; i++){
  13.               for (int j = 0; j < col; j++){
  14.                   cin >> a[i][j];   
  15.               }   
  16.           }
  17.           for (int i = 0; i < row; i++){
  18.               for (int j = 0; j < col; j++){
  19.                   b[j][i] = a[i][j];   
  20.               }
  21.           }
  22.           for (int i = 0; i < col; i++){
  23.               for (int j = 0; j < row; j++){
  24.                   cout << b[i][j] << " ";   
  25.               }
  26.               cout << endl;
  27.           }
  28.     }
  29.    
  30.     //system("pause");
  31.     return 0;
  32.    
  33. }
複製代碼
回復 2# b1081081
我是來去無蹤的..

                                ..士豪(Alen)黑輪

TOP

返回列表