Final Grade Homework:
题目要求:
1. 为一所学校编辑一款学生分数档案工具。
2. 要求如下:
a) 对所有应需记录的学生记录其分数(score)和对应的分数等级(grade)并且统计每个分数等级段有多少位学生;
b) 分类显示所有学生的总分(total),平均分(average),最低分(lowest),中位分数(medium)以及最高分(uppest);
c) 用“学生号码”,“分数”和“分数等级”将所有学生分数信息制作成一个任意图表;
d) 按“学生号码”和“分数”进行排序(sort)。
编辑范例如下:
#include <iostream>
using namespace std;
int main()
{
int n,i,j,t,score[100],SN[100],A=0,B=0,C=0,D=0,F=0,min=100,max=0,Choice=0;
char grade[100];
float sum=0,average=0,M;
cout<<"Enter number of students are: "<<flush;
cin>>n;
for(i=0; i<n; i++)
{
cout<<endl;
cout<<"Enter the score: "<<flush;
孕妇能吃芒果
cin>>score[i];
SN[i]=i+1;
if(score[i]<60)
{
grade[i]='F';
F++;
}
if((score[i]>=60)&&(score[i]<70))
{
grade[i]='D';
D++;
}
if((score[i]>=70)&&(score[i]<80))
{
grade[i]='C';
C++;
}
if((score[i]>=80)&&(score[i]<90))
{
grade[i]='B';
B++;
}
if(score[i]>=90)
{
grade[i]='A';
A++;
}
cout<<"The grade is "<<grade[i]<<"."中秋好词<<endl;
sum=sum+score[i];
if(score[i]>max)max=score[i];
if(score[i]<min)min=score[i];
}
cout<<endl;
cout<<"students who got grade 'A' have "<<A<<"."<<endl;
cout<<"students who got grade 'B' have "<<B<<"."<<endl;
cout<<"students who got grade 'C' have "<<C<<"."<<endl;
cout<<"students who got grade 'D' have "<<D<<"."<<endl;
cout<<"students who got grade 'F' have "<<F<<"."<<endl;
cout<<endl;
average=sum/n;
cout<<"The average score is "<<average<<"."<<endl;
4岁宝宝睡前故事
cout<<endl;
cout<<"The sum of the scores is: "<<sum<<endl;
cout<<endl;
cout<<"The lowest score is: "<<min<<endl;
cout<<"The uppest score is: "<<max<<endl;
cout<<endl;
M=(score[n/2]+score[(n-1)/2])/2.0;
cout<<"The medium score is "<<M<<endl;
cout<<endl;
cout<<endl;
cout<<"Student# score grade"<<endl;
for(i=0; i<n; i++)
cout<<" "<<SN[i]<<" "<<score[i]<<" "<<grade[i]<<endl;
cout<<endl;不亦乐乎是什么意思
cout<<endl;水彩怎么用
cout<<"Sorting with the information above:"<<endl;
cout<<"Choo '1': Sorting the student number column."<<endl;
cout<<"Choo '2': Sorting the score column."<<endl;
cout<<"Choo '3': Not Sort!"<<endl;
cin>>Choice;
while((Choice>=1)&&(Choice<=2))
{
if(Choice==1)
{
for(j=0;j<n-1;j++)
for(i=j;i<n-1;i++)
if(SN[j]>SN[i+1])
{
t=SN[i+1];
SN[i+1]=SN[j];
SN[j]=t;
t=score[i+1];
score[i+1]=score[j];
score[j]=t;
t=grade[i+1];
grade[i+1]=grade[j];
grade[j]=t;
}
}
if(Choice==2)
{
for(j=0;j<n-1;j++)
for(i=j;i<n-1;i++)
if(score[j]>score[i+1])un的拼音
{
t=SN[i+1];
SN[i+1]=SN[j];
SN[j]=t;
t=score[i+1];
score[i+1]=score[j];
score[j]=t;
t=grade[i+1];
grade[i+1]=grade[j];
grade[j]=t;
}
}
下定决心做某事英语
cout<<"Student# score grade"<<endl;
for(i=0; i<n; i++)
cout<<" "<<SN[i]<<" "<<score[i]<<" "<<grade[i]<<endl;
cout<<endl;白面发糕的做法
cout<<"Sorting with the information above:"<<endl;
cout<<"Choo '1': Sorting the student number column."<<endl;
cout<<"Choo '2': Sorting the score column."<<endl;
cout<<"Choo '3': Not Sort!"<<endl;
cin>>Choice;
}
return 0;
}