標題:
[作業] 陣列 (九) - 成績表 3
[打印本頁]
作者:
方浩葦
時間:
2024-7-13 09:08
標題:
[作業] 陣列 (九) - 成績表 3
新增平均欄位。
本帖隱藏的內容需要回復才可以瀏覽
作者:
林少謙
時間:
2024-7-13 15:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float a[5][4]={{90,85,85,(90.0+85.0+85.0)/3},
{76,77,43,(76.0+77.0+43.0)/3},
{78,11,22,(78.0+11.0+22.0)/3},
{43,89,88,(43.0+89.0+88.0)/3},
{98,44,67,(98.0+44.0+67.0)/3}};
string b[5]={"Adam","John","Mary","Sharon","Willion"};
cout<<"座號\t姓名\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<4; j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉奕劭
時間:
2024-7-13 15:13
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float a[5][4]={{90,85,85,(90+85+85)/3},
{70,75,80,(70+75+80)/3},
{80,95,80,(80+95+80)/3},
{70,95,75,(70+95+75)/3},
{80,85,95,(80+85+95)/3}};
string b[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\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<=3;j++){
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李唯銘
時間:
2024-7-13 15:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x;
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數學\t平均"<<endl;
for(int i=0; i<5; i++){
cout<<i+1<<"\t"<<name[i]<<"\t\t";
int x=0;
for(int j=0; j<3; j++){
cout<<score[i][j]<<"\t";
x+=score[i][j];
}
cout<<x/3;
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-7-13 16:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float s[5][4]={{90.0,85.0,85.0,(90.0+85.0+85.0)/3},
{70.0,75.0,80.0,(70.0+75.0+80.0)/3},
{80.0,95.0,80.0,(80.0+95.0+80.0)/3},
{70.0,95.0,75.0,(70.0+95.0+75.0)/3},
{80.0,85.0,95.0,(80.0+85.0+95.0)/3}};
string n[]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
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<4; j++)
{
cout<<s[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
高湘庭
時間:
2024-7-14 20:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
string name[]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][4]={{90,85,85,(90+85+85)/3},{70,75,80,(70+75+80)/3},{80,95,80,(80+95+80)/3},{70,95,75,(70+95+75)/3},{80,85,95,(80+85+95)/3}
};
cout<<"座號\t姓名\t國文\t英文\t數學\t平均"<<endl;
for(int i=0;i<5;i++)
{cout<<i+1<<"\t";
cout<<name[i];
for(int j=0;j<4;j++){
cout<<"\t"<<score[i][j];
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳妍蓁
時間:
2024-7-19 22:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"========================================================"<<endl;
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float s[5][4]={{90,85,85,(90+85+85)/3},
{70,75,80,(70+75+80)/3},
{80,95,80,(80+95+80)/3},
{70,95,75,(70+95+75)/3},
{80,85,95,(80+85+95)/3}};
for(int i=0;i<5;i++){
cout<<i+1<<"\t";
cout<<name[i]<<"\t\t";
for(int j=0;j<4;j++){
cout<<s[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2