给同学排序

10 分钟

结构体也能用 sort 排,但要告诉它按哪一项比。给学生按年龄从小到大排:bool cmp(Student a,Student b){return a.age<b.age;},再 sort(s, s+n, cmp);

小纸条

想按年龄从小到大,比较函数里写 a.age<b.age 还是 >

登录 后可看答案