標題:
陣列 (七) - 成績表 (三)
[打印本頁]
作者:
陳品肇
時間:
2019-2-16 10:07
標題:
陣列 (七) - 成績表 (三)
本帖最後由 陳品肇 於 2019-2-16 11:27 編輯
[attach]5934[/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-16 11:47
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"===================================================="<<endl;
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 a[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
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<<a[i]<<"\t\t";
for(int j=0; j<4; j++)
{
cout<<n[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
湯郡一
時間:
2019-2-16 11:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"座號"<<"\t"<<"姓名"<<"\t"<<"國文"<<"\t"<<"英文"<<"\t"<<"數學"<<"平均"<<"\t"<<endl;
cout<<"===================================================="<<endl;
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 a[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
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<<a[i]<<"\t";
for(int j=0; j<4; j++)
{
cout<<n[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
複製代碼
作者:
田宇任
時間:
2019-2-16 11:52
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"座號"<<"\t"<<"姓名"<<"\t"<<"國文"<<"\t"<<"英文"<<"\t"<<"數學"<<"\t"<<"平均"<<endl;
cout<<"============================================"<<endl;
string n[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float x[5][4]={{90,80,85,0},{70,75,80,0},{80,95,80,0},{70,95,75,0},{80,85,95,0}};
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t";
cout<<n[i]<<"\t";
x[i][3]=(x[i][0]+x[i][1]+x[i][2])/3;
for(int j=0;j<4;j++)
{
cout<<x[i][j]<<"\t";
} cout<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2