我用Netbeans编的
问题有两个:
1.输入第二个名字输不出来
2.在最后输出一个结果后判断是否继续操作,并且继续操作时返回到选择操作的菜单
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
#define NUM 5
class Student
{
public:
string name;
float math;
float chinese;
float english;
float sum;
int range;
static float aveproject[3];
static int nopass[3];
static int pretty[3];
Student(){name="";math=0;chinese=0;english=0;sum=0;}
Student(string n,float m,float c,float e):name(n),math(m),chinese(c),english(e)
{sum=math+chinese+english;}
void setmessage(string n,float m,float c,float e)
{
name=n;
math=m;
chinese=c;
english=e;
sum=math+chinese+english;
}
};
float Student::aveproject[3]={0};
int Student::nopass[3]={0};
int Student::pretty[3]={0};
void printrank(Student*s,int n)
{
int i;
for(i=0;i<n;i++)
{
cout<<setw(15)<<s[i].name<<setw(5)<<s[i].math<<setw(5)<<s[i].chinese<<setw(5)\
<<s[i].english<<setw(5)<<s[i].sum<<endl;
}
}
void printave(Student *s)
{
cout<<"数学平均分:"<<Student::aveproject[0]<<endl;
cout<<"语文平均分:"<<Student::aveproject[1]<<endl;
cout<<"英语平均分:"<<Student::aveproject[2]<<endl;
}
void printnopass(Student *s)
{
cout<<"数学不及格人数:"<<Student::nopass[0]<<endl;
cout<<"语文不及格人数:"<<Student::nopass[1]<<endl;
cout<<"英语不及格人数:"<<Student::nopass[2]<<endl;
}
void printpretty(Student *s)
{
cout<<"数学优秀人数:"<<Student::pretty[0]<<endl;
cout<<"语文优秀人数:"<<Student::pretty[1]<<endl;
cout<<"英语优秀人数:"<<Student::pretty[2]<<endl;
}
int main()
{
}
for(i=0;i<3;i++)
Student::aveproject[i]=pro[i]/NUM;
for(i=0;i<NUM;i++)
{
for(j=i;j<NUM;j++)
{
if(stud[i].sum<stud[j].sum)
{
temp.setmessage(stud[i].name,stud[i].math,stud[i].chinese,stud[i].english);
stud[i].setmessage(stud[j].name,stud[j].math,stud[j].chinese,stud[j].english);
stud[j].setmessage(temp.name,temp.math,temp.chinese,temp.english);
}
}
}
do
{
cout> flag;
switch (flag)
{
case 1:
printrank(stud,NUM);
break;
case 2:
printave(stud);
break;
case 3:
printnopass(stud);
break;
case 4:
printpretty(stud);
break;
default:break;
}
cout>flag;
}while (flag=='y'||flag=='Y') ;
return 0;
}
这是剩下的,做好加悬赏100谢谢!