標題:
[隨堂測驗] 陣列 (七) - 電話簿
[打印本頁]
作者:
方浩葦
時間:
2024-7-13 09:08
標題:
[隨堂測驗] 陣列 (七) - 電話簿
試以二維陣列的概念,輸出如下的電話簿。
本帖隱藏的內容需要回復才可以瀏覽
作者:
林少謙
時間:
2024-7-13 14:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string a[5][2]={{"大熊","0900 000 000"},
{"胖虎","0911 111 111"},
{"小夫","0922 222 222"},
{"靜香","0933 333 333"},
{"多拉A夢","0944 444 444"}};
cout<<"姓名\t電話"<<endl;
cout<<"================="<<endl;
for(int i=0; i<5; i++)
{
for(int j=0; j<2; j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉奕劭
時間:
2024-7-13 14:44
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string a[5][2]={{"大雄","0980-454666"},
{"季安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
cout<<"姓名\t電話"<<endl;
cout<<"==========================="<<endl;
for(int i=0;i<=4;i++){
cout<<i+1<<"\t";
for(int j=0;j<=1;j++){
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李唯銘
時間:
2024-7-13 14:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n[5][2]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
cout<<"姓名\t電話"<<endl;
for(int i=0; i<5; i++){
for(int j=0; j<2; j++){
cout<<n[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李偈睿
時間:
2024-7-13 15:18
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string a[5][2]={{"大熊","0900 000 000"},
{"胖虎","0911 111 111"},
{"小夫","0922 222 222"},
{"靜香","0933 333 333"},
{"多拉A夢","0944 444 444"}};
cout<<"姓名\t電話"<<endl;
cout<<"================="<<endl;
for(int i=0 ; i<5 ;i++)
{
cout<<i+1<<"\t";
for(int j=0 ; j<2 ;j++)
cout<<a[i][j]<<"\t";
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-7-13 15:25
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n[5][2]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
cout<<"姓名\t電話"<<endl;
cout<<"==================="<<endl;
for(int i=0; i<5; i++)
{
for(int j=0; j<2; j++)
cout<<n[i][j]<<"\t";
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳妍蓁
時間:
2024-7-13 15:27
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
string n[5][2]={{"大雄","0980-454666"},
{"季安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
cout<<"姓名\t電話\t"<<endl;
cout<<"========================="<<endl;
for(int i=0;i<5;i++){
for(int j=0;j<2;j++){
cout<<n[i][j]<<"\t";
}cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
高湘庭
時間:
2024-7-14 15:51
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
string phone[5][2]={
{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911864356"}
};
cout<<"姓名\t電話"<<endl;
cout<<"============"<<endl;
for(int i=0;i<5;i++)
{
for(int j=0;j<2;j++)
{
cout<<phone[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2