#include<iostream> #include<string> #include <map> #include <vector> #include <sstream> using namespace std; int main() { string input; cin>>input; multimap<int,string> mup; vector<string> vString; vector<int> vCount; string scount = ""; string temp = ""; for(int i=0; i<input.size();i++) { if (input[i] >= '0' && input[i] <= '9') { if(temp != "") { vString.push_back(temp); //vCount.push_back(input[i]-'0'); scount+=input[i]; temp = ""; } else { scount+=input[i]; } } else { if (scount != "") { stringstream ss; ss<<scount; int t; ss>>t; vCount.push_back(t); scount = ""; } temp += input[i]; } } stringstream ss; ss<<scount; int t; ss>>t; vCount.push_back(t); for (int i=0;i<vCount.size();i++) { mup.insert(make_pair(vCount[i],vString[i])); } string result = ""; multimap<int,string>::iterator it; for(it = mup.begin();it != mup.end();++it) { int n = it->first; string s = it->second; for(int i=0; i<n; i++) { result+=s; } } cout << result << endl; return 0; }
点赞 评论

相关推荐

10-30 12:55
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
牛客网
牛客企业服务