#include <algorithm>
#include <iostream>
#include <iomanip>
using std::cout;
using std::endl;
struct Student
{
public:
int iGrade1;
int iGrade2;
int iGrade3;
bool operator < (const Student& other) const
{
return (iGrade1 < other.iGrade1) || (!(other.iGrade1 < iGrade1) && (iGrade2 < other.iGrade2))
|| (!(other.iGrade2 < iGrade2) && iGrade3 < other.iGrade3);
}
};
void Print(Student* pStu, int iCount)
{
if (NULL == pStu)
{
return;
}
for(int i = 0; i < iCount; ++i)
{
cout << pStu[i].iGrade1 << "\t" << pStu[i].iGrade2 << "\t" << pStu[i].iGrade3 << endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
Student stus[] = { {100, 100, 100}, {100, 100, 90}, {100, 100, 80}, {100, 100, 99}, {100, 100, 50},
{100, 80, 100}, {100, 80, 60}, {10, 10, 100}, {10, 30, 100}, {100, 70, 60},
{100, 70, 100}, {100, 60, 60}, {86, 10, 100}, {77, 30, 100}, {76, 70, 60}, };
std::sort(stus, stus + _countof(stus));
Print(stus, _countof(stus));
return 0;
}