標題:
陣列 (七) - 成績表 (二)
[打印本頁]
作者:
tonyh
時間:
2014-1-18 17:31
標題:
陣列 (七) - 成績表 (二)
本帖最後由 tonyh 於 2014-1-18 17:44 編輯
新宣告一維陣列, 以用來插入姓名欄位, 如下圖所示.
[attach]809[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][3]={{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<=4; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0; j<=2; j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2014-1-18 17:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score[5][3]={{85,80,75},
{90,85,88},
{95,97,98},
{75,85,77},
{84,75,70}};
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<=4;i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0;j<=2;j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2014-1-18 17:40
本帖最後由 張峻瑋 於 2014-1-18 17:41 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
int a[5][3]={{ 90 , 95 , 80 },
{ 80 , 70 , 90 },
{ 90 , 85 , 90 },
{ 95 , 95 , 80 },
{ 80 , 90 , 90 }};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<=4;i++)
{
cout<<i+1<<"\t";
cout<<name[i]<<"\t\t";
for(int j=0;j<=2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2014-1-18 17:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"黑子","紫原","赤司","綠間","黃瀨"};
float score [5][3]={{90,95,85},
{89,95,92},
{89,95,92},
{89,95,92},
{89,95,92}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t"<<endl;
cout<<"============================================="<<endl;
for(int i=0;i<=4;i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t"<<"\t";
for(int j=0;j<=2;j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2014-1-18 17:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float a[5][3]={{100,100,100},
{100,100,100},
{100,100,100},
{100,100,100},
{100,100,100}};
string n[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"Number \tName\t\tChinese\tEnglish\tMath\t"<<endl;
cout<<"----------------------------------------------"<<endl;
for(int i=0; i<=4; i++)
{
cout<<i+1<<"\t"<<n[i]<<"\t\t";
for(int j=0; j<=2 ;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2014-1-18 17:44
#include<iostream>
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][3]={{96,92,91},
{94,98,92},
{97,85,89},
{97,95,91},
{85,94,97}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<=4;i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0;j<=2;j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2014-1-18 18:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float a[5][4]={{100,100,100,0},
{100,100,100,0},
{100,100,100,0},
{100,100,100,0},
{100,100,100,0}};
string n[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"Number\tName\t\tChinese\tEnglish\tMath\tAvarage\t"<<endl;
cout<<"-------------------------------------------------------"<<endl;
for(int i=0; i<=4; i++)
{
a[i][3]=(a[i][0]+a[i][1]+a[i][2])/3;
cout<<i+1<<"\t"<<n[i]<<"\t\t";
for(int j=0; j<=3;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2014-1-24 20:00
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
float score[5][3]={{90,98,89},
{76,83,85},
{91,87,94},
{76,82,78},
{91,86,95}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t"<<endl;
cout<<"============================================"<<endl;
for(int i=0; i<=4; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0; j<=2; j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2014-1-24 20:01
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[5]={"王小明","大張郎","王小安","邱裕仁","張好醜"};
float score[5][3]={{97,85,85},
{74,78,83},
{81,95,81},
{79,97,75},
{87,85,95}};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t"<<endl;
cout<<"============================================"<<endl;
for(int i=0; i<=4; i++)
{
cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0; j<=2; j++)
{
cout<<score[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2