htdwade:#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;
vector<int> nums;
while(cin >> x){
nums.push_back(x);
}
auto cmp = [](const int& a, const int& b){
return to_string(a) + to_string(b) < to_string(b) + to_string(a);
};
sort(nums.begin(), nums.end(), cmp);
string s;
for(auto a : nums)
s += to_string(a);
int index = 0;
while(index < s.size() && s[index] == '0')
index++;
if(index == s.size())
cout << 0 << endl;
else
cout << s.substr(index) << endl;
return 0;
} 第二题直接调正则库解决了= = #include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
while(cin >> s){
regex pattern("[-]?\\d+");
auto numBeg = sregex_iterator(s.begin(), s.end(), pattern);
auto numEnd = sregex_iterator();
int res = 0;
for(auto i = numBeg; i != numEnd; ++i){
smatch match = *i;
string t = match.str();
res += stoi(t);
}
cout << res << endl;
}
}
投递虎牙等公司10个岗位 >
0 点赞 评论 收藏
分享
关注他的用户也关注了: