返回列表 發帖

[隨堂測驗] 陣列 (七) - 電話簿

試以二維陣列的概念,輸出如下的電話簿。


本帖隱藏的內容需要回復才可以瀏覽

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string score[5][2]={{"大維", "0980-454666"},
  7.                      {"技安", "0911-333898"},
  8.                      {"宜靜", "0922-999579"},
  9.                      {"阿福", "0938-234567"},
  10.                      {"小叮噹", "0911-864356"}};
  11.    
  12.     cout<<"姓名\t電話"<<endl;
  13.     cout<<"============================"<<endl;
  14.     for(int i=0; i<5; i++)
  15.     {
  16.         cout<<i+1<<"\t";
  17.         for(int j=0; j<2; j++)
  18.              cout<<score[i][j]<<"\t";
  19.         cout<<endl;
  20.     }
  21.     system("pause");
  22.     return 0;
  23. }
複製代碼

TOP

返回列表