可以对cmp函数进行重写然后调用sort就行了,代码如下 bool cmp(long long a, long long b) { if (a % 10 != b % 10) return a % 10 < b % 10; return a < b; } void Sort_out(vector<long long>& val) { sort(val.begin(), val.end(), cmp); vector<long long>::iterator it = val.begin(); while (it != val.end()) { cout << *it << endl; it++; } }
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务