標題:
[隨堂測驗] 修改成績
[打印本頁]
作者:
張翼安
時間:
2016-3-26 10:29
標題:
[隨堂測驗] 修改成績
本帖最後由 張翼安 於 2016-3-26 10:54 編輯
1.
顯示
5個同學的5科成績
2.
調出
該同學的單科成績
3.
修改
該同學的單科成績
4.顯示修改之後的5個同學的5科成績
P.S 當使用者輸入-1之後,顯示修改之後的5個同學的5科成績。
作者:
蔡庭豪
時間:
2016-3-26 11:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,z;
string sub[5]={"國文","英文","數學","物理","化學"};
cout<<"座號 姓名 ";
for(int a=0;a<5;a++)
{
cout<<sub[a]<<"\t";
}
cout<<endl;
cout<<"======================================================"<<endl;
string name[5]={"甲","乙","丙","丁","戊"};
int array[5][5]={{91,92,93,94,95},{80,81,82,83,84},{71,72,73,74,75},{95,91,92,93,45},{87,78,87,74,44}};
for(int c=0;c<5;c++)
{
cout<<" "<<c+1<<" "<<name[c]<<" ";
for(int d=0;d<5;d++)
{
cout<<" "<<array[c][d]<<"\t";
}
cout<<endl;
}
cout<<endl;
cout<<"請問要調查哪位同學的成績?(甲:1,乙:2,丙:3,丁:4,戊:5)"<<endl;
cin>>x;
cout<<"請問要調查哪個科目?(國文:1,英文:2,數學:3,物理:4,化學:5)"<<endl;
cin>>y;
cout<<name[x-1]<<"同學"<<sub[y-1]<<array[x-1][y-1]<<"分"<<endl;
cout<<"請問要修改幾分?"<<endl;
cin>>z;
array[x-1][y-1]=z;
cout<<"座號 姓名 ";
for(int a=0;a<5;a++)
{
cout<<sub[a]<<"\t";
}
cout<<endl;
cout<<"======================================================"<<endl;
for(int c=0;c<5;c++)
{
cout<<" "<<c+1<<" "<<name[c]<<" ";
for(int d=0;d<5;d++)
{
cout<<" "<<array[c][d]<<"\t";
}
cout<<endl;
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡季樺
時間:
2016-3-26 11:58
本帖最後由 蔡季樺 於 2016-4-7 19:00 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int number,SG;
int point[5][5]={{100,98,75,89,70},
{87,85,91,86,80},
{97,99,94,96,90},
{79,74,81,69,65},
{95,93,88,92,84}};
string name[5]={"甲","乙","丙","丁","戊"},
subject[5]={"國語","英文","數學","物理","化學"};
cout<<"請問要調出哪一位同學的成績"<<endl;
for(int i=0;i<=4;i++)
cout<<"("<<i+1<<")"<<name[i]<<endl;
cout<<":";
cin>>number;
cout<<"請問要調出哪一科的成績"<<endl;
for(int j=0;j<=4;j++)
cout<<"("<<j+1<<")"<<subject[j]<<endl;
cout<<":";
cin>>SG;
cout<<name[number-1]<<"同學的";
cout<<subject[SG-1]<<"成績:"<<point[number-1][SG-1]<<endl;
cout<<"請問要修改成幾分:";
cin>>point[number-1][SG-1];
cout<<"座號"<<"\t";
for(int k=0;k<=4;k++)
{
cout<<subject[k]<<"\t";
}
cout<<endl;
cout<<"======================================"<<endl;
for(int l=0;l<=4;l++)
{
cout<<name[l]<<"\t";
for(int m=0;m<=4;m++)
{
cout<<point[l][m]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張健勳
時間:
2016-3-26 12:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string student[5]={"甲","乙","丙","丁","戊"};
string subject[5]={"國","英","數","物","化"};
int array[5][5]={{60,61,62,63,64},
{31,32,33,34,35},
{61,62,63,64,65},
{41,42,43,44,45},
{36,37,38,39,49}};
int j;
int i;
cout << "請問要調出哪一位同學的成績表" << endl;
cin >> j;
cout << "請問要調出哪一科的成績" ;
for(int x = 0; x < 5; x++)
{
cout << x + 1 << ":" << subject[x];
}
cin >> i;
cout << "請問你要改幾分" ;
int z;
cin >> z;
array[j-1][i-1]=z;
for(int c=0;c<5;c++)
{
cout<<" "<<c+1<<" "<<student[c]<<" ";
for(int d=0;d<5;d++)
{
cout<<" "<<array[c][d]<<"\t";
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2