標題:
陣列 (八) - 成績表 (三)
[打印本頁]
作者:
tonyh
時間:
2015-3-7 10:46
標題:
陣列 (八) - 成績表 (三)
本帖最後由 tonyh 於 2015-3-7 11:10 編輯
新增平均欄位.
[attach]1159[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][4]={{80,87,68,0},{70,89,88,0},{67,66,50,0},{45,43,68,0},{77,55,79,0}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"========================================================="<<endl;
for(int i=0; i<5; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\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;
}
複製代碼
作者:
洪振庭
時間:
2015-3-7 11:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][4]={{90,85,85,0},{70,75,80,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"<<name[i]<<"\t\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;
}
複製代碼
作者:
李大全
時間:
2015-3-7 11:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][4]={{80,87,68,0},{70,89,88,0},{67,66,50,0},{45,43,68,0},{77,55,79,0}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"========================================================="<<endl;
for(int i=0; i<5; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\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;
}
複製代碼
作者:
李知易
時間:
2015-3-7 11:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][4]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"==============================================================="<<endl;
for(int i=0; i<5; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\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;
}
複製代碼
作者:
謝瀞儀
時間:
2015-3-7 11:17
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float n[5][4]={{15,17,150,0},{395,413,406,0},
{16,85,18,0},{100,17,35,0},{19,21,17,0}};
string name[5]={"吉井明久","姬路瑞希","島田美波","木下秀吉","土屋康太"};
cout<<"No.\t 姓名\t 國\t英\t社\t平均"<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
int i=0;
while(i<5)
{
n[i][3]=(n[i][0]+n[i][1]+n[i][2])/2;
cout<<i+1<<"\t";
cout<<name[i]<<"\t";
for(int j=0;j<4;j++)
{
cout<<n[i][j]<<"\t";
}
i++;
cout<<"\n";
}
system("pause");
return 0;
}
複製代碼
作者:
梁和雋
時間:
2015-3-7 11:20
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][4]={{80,87,68,0},{70,89,88,0},{67,66,50,0},{45,43,68,0},{77,55,79,0}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
cout<<"========================================================="<<endl;
for(int i=0; i<5; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2