返回列表 發帖

陣列 (四) - 二維陣列

本帖最後由 tonyh 於 2018-6-20 17:21 編輯

一個 3x4 的二維陣列, 總共可以儲存 12 筆資料.

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}};
  7.     for(int i=0; i<3; i++)
  8.     {
  9.         for(int j=0; j<4; j++)
  10.              cout<<"n["<<i<<"]["<<j<<"]="<<n[i][j]<<endl;     
  11.     }
  12.     system("pause");
  13.     return 0;      
  14. }
複製代碼

返回列表