#include
#include
#include
#include
#include
using namespace std;
struct Book
{
string Name;
int Year;
int Price;
};
bool CompName(const Book &b1,const Book &b2)
{
if(b1.Name!=b2.Name)
return b1.Name
return b1.Year
return b1.Price
bool CompYear(const Book &b1,const Book &b2)
{
if(b1.Year!=b2.Year)
return b1.Year
return b1.Name
return b1.Price
bool CompPrice(const Book &b1,const Book &b2)
{
if(b1.Price!=b2.Price)
return b1.Price
return b1.Name
return b1.Year
int main()
{
//ifstream cin("acmilan.txt");
vector
Book book;
string sorting;
int n;
int i;
int line=0;
while(cin>>n)
{
if(n==0)
break;
line++;
v.clear();
for(i=0;i
cin>>book.Name>>book.Year>>book.Price;
v.push_back(book);
}
cin>>sorting;
if(sorting=="Name")
sort(v.begin(),v.end(),CompName);
else if(sorting=="Year")
sort(v.begin(),v.end(),CompYear);
else if(sorting=="Price")
sort(v.begin(),v.end(),CompPrice);
if(line!=1)
cout<
cout<
}
//system("pause");
return 0;
}
作者:teibin