標題:
陣列 (七) - 成績表 (三)
[打印本頁]
作者:
陳品肇
時間:
2019-2-1 21:18
標題:
陣列 (七) - 成績表 (三)
本帖最後由 陳品肇 於 2019-2-1 21:20 編輯
[attach]5888[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王一美","王二美","王三美","王四美","王五美"};
float score[5][4] ={{90,90,85,0} ,
{70,75,85,0},
{80,95,80,0},
{70,95,75,0},
{80,85,95,0}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"===================================================="<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t"; // 印座號
cout<< name[i]<<"\t\t"; //印姓名
//[0][3]= ([0][0]+[0][1]+[0][2])/3
score[i][3] = (score[i][0]+score[i][1]+score[i][2])/3; //算出平均
for(int j=0;j<4;j++)
{
cout<<score[i][j]<<"\t"; //印出成績
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
曲書辰
時間:
2019-2-2 14:44
本帖最後由 曲書辰 於 2019-2-2 15:12 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float n[5][4]={{90,85,85,0},
{70,75,80,0},
{80,95,80,0},
{70,95,75,0},
{80,85,95,0}};
string n4[5]={"王大明","李大頭","蘇小美","余美美","張醜醜"};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"==========================================================="<<endl;
for(int i=0;i<5;i++)
{
n[i][3]=(n[i][0]+n[i][1]+n[i][2])/3;
cout<<i+1<<"\t";
cout<<n4[i]<<"\t\t";
for(int j=0;j<4;j++)
{
cout<<n[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
章幼莛
時間:
2019-2-2 15:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王一美","王二美","王三美","王四美","王五美"};
float f[5][4]={{90,90,85,0},
{70,75,85,0},
{80,95,80,0},
{70,95,75,0},
{80,85,95,0}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"===================================================="<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t";
cout<<name[i]<<"\t\t";
f[i][3]=(f[i][0]+f[i][1]+f[i][2])/3;
for(int j=0;j<4;j++)
{
cout<<f[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
回復
1#
陳品肇
作者:
吳孟修
時間:
2019-2-2 15:13
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float a[5][4]={{90,90,85,0},{70,75,85,0},{80,95,80,0},{70,95,75,0},{80,85,95,0}};
string b[5]={"王一美","王二美","王三美","王四美","王五美"};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"===================================================="<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t"<<b[i]<<"\t\t";
a[i][3]=(a[i][0]+a[i][1]+a[i][2])/3;
for(int j=0;j<4;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
王瑞喻
時間:
2019-2-2 15:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float n[5][4]={{90,85,85,0},
{70,75,80,0},
{80,95,80,0},
{70,95,75,0},
{80,85,95,0}};
string b[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t國文\t英文\t數學\t平均"<<endl;
for(int i=0;i<5;i++)
{
n[i][3]=(n[i][0]+n[i][1]+n[i][2])/3;
cout<<i+1<<"\t"<< b[i]<<"\t";
for(int j=0;j<4;j++)
{
cout<<n[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
洪寬瀧
時間:
2019-2-2 15:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{ string name[5]={"王一美","王二美","王三美","王四美","王五美"};
float score[5][4]={{90,90,85,0},{70,75,85,0},{80,95,80,0},{80,85,95,0},{70,95,75,0}};
cout<<"座號\t姓名\t國文\t英文\t數學\t平均"<<endl;
cout<<"==========================================="<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t";
cout<<name[i]<<"\t";
score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
for(int j=0;j<4;j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
吳孟書
時間:
2019-2-13 21:02
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float s[5][4]={{90,90,85,0},{70,75,85,0},{80,95,80,0},{70,95,75,0},{80,85,95,0}};
string n[5]={"王一美","王二美","王三美","王四美","王五美"};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"===================================================="<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t";
cout<<n[i]<<"\t\t";
s[i][3]=(s[i][0]+s[i][1]+s[i][2])/3;
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