#include
#include
class student
{
private:
int num ;
float score;
string name;
public:
void set()
{ cout<<"\n学号:" ;
cin>>num;
cout<<"\n成绩:";
cin>>score;
cout<<"\n姓名:" ;
cin>>name;
}
void print()
{cout<<"\n学号:"<
float getScore(){return score;}
};
int main()
{
student a[3];
int i,j,k=0;
for(i=0;i<3;++i)
a[i].set();
for(j=0;j<2;++j)
{ if(a[j].getScore() k=j+1;
}
a[k].print();
return 0;
}
#include
#include
class
student
{
private:
int
num
;
float
score;
string
name;
public:
void
set()
{
cout<<"\n学号:"
;
cin>>num;
cout<<"\n成绩:";
cin>>score;
cout<<"\n姓名:"
;
cin>>name;
}
void
print()
{cout<<"\n学号:"<
float
getScore(){return
score;}
};
int
main()
{
student
a[3];
int
i,j,k=0;
for(i=0;i<3;++i)
a[i].set();
for(j=0;j<2;++j)
{
if(a[j].getScore()k=j+1;
}
a[k].print();
return
0;
}
建个类 写个冒泡排序 不就o了