// 贴上第二个代码,只通过了60% #include <iostream> #include <vector> #include <algorithm> struct X { int priority; int order; X(int p, int o) : priority(p), order(o) {} friend bool operator<(const X& lhs, const X& rhs); }; bool operator<(const X& lhs, const X& rhs) { return lhs.priority > rhs.priority; } void printOrder(const int input[], int len, int output[]) { if (len == 0) return; std::vector<X> xs; xs.reserve(len); for (int i = 0; i < len; ++i) { xs.emplace_back(input[i], i); } std::stable_sort(xs.begin(), xs.end()); for (int i = 0; i < len; ++i) { output[i] = xs[i].order; } } int main() { char in; std::vector<int> temp; while (std::cin >> in) { if (in == ',') continue; temp.push_back(in - '0'); } int *input = new int[temp.size()]; int *output = new int[temp.size()]; int len = temp.size(); for (int i = 0; i < len; ++i) *(input + i) = temp[i]; printOrder(input, len, output); for (int i = 0; i < len; ++i) { if (i == 0) std::cout << output[i]; else std::cout << ", " << output[i]; } }
点赞 评论

相关推荐

都来卷JAVA,卷④tmd😂😂
喝茶写代码:Java真太卷了,一片红海,我和身边双9电子信息转Java的人都没有大厂后端的offer,甚至很多简历都过不去
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
08-14 22:16
我爱加瓦233:今年行情真的好起来了,暑期实习拿了美团,京东,饿了么三家的Offer,最终去了美团,披上了我的黄马褂,开启送外卖之旅
点赞 评论 收藏
分享
用微笑面对困难:不是你千万别小看这家公司,他们的预估市值成倍上涨,三次在报告看见这个公司了,总之如果是给股权的话可以试试,未来没准真能发家致富哈哈哈哈
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务