標題:
[隨堂測驗] 陣列 (八) - 成績表 2
[打印本頁]
作者:
方浩葦
時間:
2024-7-13 09:08
標題:
[隨堂測驗] 陣列 (八) - 成績表 2
新宣告一個一維陣列,以用來插入姓名欄位,如下圖所示。
本帖隱藏的內容需要回復才可以瀏覽
作者:
林少謙
時間:
2024-7-13 14:26
本帖最後由 林少謙 於 2024-7-13 15:02 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a[5][3]={{43,55,77},
{76,77,43},
{78,11,22},
{43,89,88},
{98,44,67}};
string b[]={"Adam","John","Mary","Sharon","Willion"};
cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
cout<<"=============================================="<<endl;
for(int i=0; i<5; i++)
{
cout<<i+1<<"\t";
cout<<b[i]<<"\t\t";
for(int j=0; j<3; 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()
{
int a[5][3]={{43,55,77},
{76,77,43},
{78,11,22},
{43,89,88},
{98,44,67}};
string b[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t國文\t英文\t數學"<<endl;
cout<<"====================================="<<endl;
for(int i=0;i<=4;i++){
cout<<i+1<<"\t";
cout<<b[i]<<"\t";
for(int j=0;j<=2;j++){
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李唯銘
時間:
2024-7-13 15:03
本帖最後由 李唯銘 於 2024-7-13 15:11 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score[5][4]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
for(int i=0; i<5; i++){
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0; j<3; j++){
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李偈睿
時間:
2024-7-13 15:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a[5][3]={{43,55,77},
{76,77,43},
{78,11,22},
{43,89,88},
{98,44,67}};
string b[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t國文\t英文\t數學"<<endl;
cout<<"====================================="<<endl;
for(int i=0;i<=4;i++)
{
cout<<i+1<<"\t";
cout<<b[i]<<"\t";
for(int j=0;j<=2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳妍蓁
時間:
2024-7-13 15:39
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int score[5][3]={{90,85,85},
{90,86,86},
{90,87,87},
{90,88,88},
{90,89,89}};
string n[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t國文\t英文\t數學\t"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t";
cout<<n[i]<<"\t";
for(int j=0;j<3;j++){
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-7-13 15:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int s[5][3]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
string n[]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t國語\t英文\t數學"<<endl;
cout<<"===================================="<<endl;
for(int i=0; i<5; i++)
{
cout<<i+1<<"\t";
cout<<n[i]<<"\t";
for(int j=0; j<3; j++)
{
cout<<s[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
高湘庭
時間:
2024-7-14 16:20
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main(){
//<法1一維陣列>
string name[]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
int chinese[] = {90,70,80,70,80};
int english[] = {85,75,95,95,85};
int math[] = {85,80,80,75,95};
cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<5;i++)
{cout<<i+1<<"\t";
cout<<name[i]<<"\t"<<"\t"<<chinese[i]<<"\t"<<english[i]<<"\t"<<math[i]<<"\t";
cout<<endl;
}
cout<<endl;
//<法2二維陣列>
int score[5][3] = {
{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}
};
cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<5;i++){
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0;j<3;j++){
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2