#include <iostream>
using namespace std;
int main()
{
int grade[31],g;
int sum=0,MING=0,MAXG=0,MINS=0,MAXS=0;
char name[31],n;
cout<<"Please input student name and this grade:" ;
cout<<endl;
for(int i=0;i<=10;i++)
{
cin>>n>>g;
name[i]=n;
grade[i]=g;
sum=grade[i]+sum;
}
int j=0;
MING=MAXG=grade[0];
MINS=MAXS=0;
while(j<=10)
{
j++;
if(MING>grade[j])
{
MING=grade[j];
MINS=j;
}
if(MAXG<grade[j])
{
MAXG=grade[j];
MAXS=j;
}
}
int average;
average=sum/10;
cout<<"average: "<<average<<endl;
if(MING<average)
{
cout<<"MIN: "<<endl;
cout<<" "<<name[MINS]<<" below the class average.";
cout<<endl;
cout<<endl;
}
else
{
cout<<"MIN: "<<endl;
cout<<" "<<"no everybody below the class average.";
cout<<'\n';
cout<<endl;
}
cout<<"AVERAGE: "<<"THE CLASS STUDENT AVERAGE :"<<average<<'\n';
cout<<endl;
cout<<"MAX: "<<endl;
cout<<" HIGH SCORE:"<<MAXG<<'\n';
cout<<" "<<name[MAXS]<<" HIGH SCORE FOR THE CLASS."<<endl;
return 0;
}
工作原因,有时加班,断断续续的学习c++,基本上课程也看完,就是缺少锻炼,也因此二级没过。
这是课本里的习题,好像没有答案。
欢迎给位读者提出宝贵意见。