標題:
[訂正] 陣列 (八) - 成績表 2
[打印本頁]
作者:
陳育霖
時間:
2024-3-16 20:01
標題:
[訂正] 陣列 (八) - 成績表 2
新宣告一個一維陣列,以用來插入姓名欄位,如下圖所示。
本帖隱藏的內容需要回復才可以瀏覽
作者:
謝崇亘
時間:
2024-3-16 20:09
#include<iostream>
using namespace std;
int main()
{
int a[5][3]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
string d[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t"<<d[i]<<"\t\t";;
for(int j=0;j<3;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
楊子毅
時間:
2024-3-16 20:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int ted[5][3]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout<<"座號\t姓名\t\t國文\t英文\t數學\n";
for(int i=0; i<45;i++)
{cout<<"=";
}
cout<<endl;
for(int i=0;i<5;i++)
{cout<<i+1<<"\t"<<name[i]<<"\t\t";
for(int j=0;j<3;j++)
{
cout<<ted[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蘇巳權
時間:
2024-3-16 20:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int b[5][3]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,70},
{80,85,90}};
string a[5]={"王大明\t","李大頭\t","蘇小安\t","余美美\t","張醜醜\t"};
cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
cout<<"============================================"<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<"\t"<<a[i]<<"\t";
for(int j=0;j<3;j++)
{
cout<<b[i][j]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳宥澄
時間:
2024-3-16 20:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x[5][3] = {{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
string n[5] = {"王大明","李大頭","蘇小安","余美美","張醜醜"};
cout << "座號\t" << "姓名\t\t" << "國文\t" << "英文\t" << "數學\n";
cout << "==========================================\n";
for(int i=0; i<5; i++)
{
cout << i+1 << "\t" << n[i] << "\t\t";
for(int j=0; j<3; j++)
{
cout << x[i][j] << "\t";
}
cout << endl;
}
system("pause");
return 0;
}
複製代碼
作者:
詠綺
時間:
2024-3-23 20:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
float b=0;
float i[5][3]={{90, 85, 85}, {70, 75, 80}, {80, 95, 80}, {70, 95, 75}, {80, 95, 80}};
string a[5]={"王大明", "李大頭", "蘇小安", "余美美", "張醜醜"};
cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均\n";
for(int j=0;j<5;j++)
{
cout<<j+1<<"\t";
cout<<a[j]<<"\t\t";
for(int s=0;s<3;s++)
{
cout<<i[j][s]<<"\t";
b=b+i[j][s];
}
cout<<b/3;
b=0;
cout<<"\n";
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2