标签:out lis 自定义 链表排序 pop back turn 插入 i++
#include<iostream> #include<list> #include<string> using namespace std; struct student{ int grade,age; string name; friend bool operator < (student a, student b){ return a.grade < b.grade; } }; int main(){ list<student>l; student n[4] = { {3,3,"Kite"}, {2,1,"Jack"}, {0,7,"Bob"}, {5,6,"Rose"} }; for(int i=0;i<4;i++) l.push_back(n[i]); l.sort(); for(auto i:l){ cout << i.name << ‘ ‘ << i.grade << endl; } return 0; }
标签:out lis 自定义 链表排序 pop back turn 插入 i++
原文地址:https://www.cnblogs.com/Cmathe/p/12263239.html