標題:
[作業]修改成績(二)
[打印本頁]
作者:
張翼安
時間:
2016-3-26 11:59
標題:
[作業]修改成績(二)
1.調出該同學的單科成績
2.修改該同學的單科成績
3.顯示修改之後的5個同學的5科成績
P.S 當使用者輸入-1之後,顯示修改之後的5個同學的5科成績。
提示:使用While迴圈,直到輸入-1結束,才顯示所有成績
作者:
吳承勳
時間:
2016-3-28 17:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,score;
string sub[5]={"國文","英文","數學","物理","化學"};
string name[5]={"甲","乙","丙","丁","戊"};
int array[5][5]={{100,100,100,100,5},{45,56,82,95,46},{78,90,86,65,85},{75,91,56,99,55},{45,72,54,45,24}};
cout<<"請問要調查哪位同學的成績?(甲:1,乙:2,丙:3,丁:4,戊:5)"<<endl;
cin>>x;
while(x!=-1){
cout<<"請問要調查哪個科目?(國文:1,英文:2,數學:3,物理:4,化學:5)"<<endl;
cin>>y;
cout<<name[x-1]<<" "<<sub[y-1]<<" "<<array[x-1][y-1]<<"分"<<endl;
cout<<"請問要修改成幾分: ";
cin>>score;
array[x-1][y-1]=score;
cout<<"請問要調查哪位同學的成績?(甲:1,乙:2,丙:3,丁:4,戊:5)"<<endl;
cin>>x;
}
system("cls");
cout<<"學號\t姓名\t";
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;
}
system("pause");
return 0;
}
複製代碼
作者:
蔡季樺
時間:
2016-4-7 18:56
#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;
while(number!=-1)
{
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;
}
cout<<"請問要調出哪一位同學的成績"<<endl;
cin>>number;
}
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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2