aaa
#include <iostream>
#include <string>
using namespace std;
class Cat
{
private:
string name;
double weight;
public:
void getName(string c_name) {
name = c_name;
}
void getWeight(double c_weight) {
weight = c_weight;
}
string getN() {
return name;
}
double getW() {
return weight;
}
};
void swap(Cat&a, Cat&b)
{
if (a.getW() > b.getW())
{
Cat temp;
temp = a;
a = b;
b = temp;
}
}
int main()
{
int n,i,j;
cin >> n;
Cat *cat = new Cat[n];
string name;
double weight;
for (int i = 0; i < n; i++) {
cin >> name >> weight;
cat[i].getName(name);
cat[i].getWeight(weight);
}
for (int i = 0; i < n; i++) //冒泡排序
{
for (int j = i; j < n; j++)
{
swap(cat[i], cat[j]);
}
}
for (int i = 0; i < n; i++)
{
cout << cat[i].getN() << " ";
}
delete []cat;
return 0;
}