关注
#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;
}
}
查看原帖
点赞 评论
相关推荐
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 牛客吐槽大会 #
14874次浏览 229人参与
# 实习,不懂就问 #
159806次浏览 1416人参与
# 晒晒你司的新年福利 #
1432次浏览 25人参与
# 国企秋招,你投了吗? #
58997次浏览 377人参与
# 程序员找工作至少要刷多少题? #
1601次浏览 24人参与
# 暑假倒计时,你都干了些啥? #
39582次浏览 207人参与
# 硬件/芯片公司工作体验 #
146890次浏览 960人参与
# 软开人,秋招你打算投哪些公司呢 #
178626次浏览 1355人参与
# 硬件人秋招进展 #
269468次浏览 3983人参与
# 毕业后不工作的日子里我在做什么 #
233001次浏览 1691人参与
# 帆软软件工作体验 #
11521次浏览 55人参与
# 运营人求职交流聚集地 #
208704次浏览 1091人参与
# 学历or实习经历,哪个更重要 #
232918次浏览 1225人参与
# 实习越久越好,还是多多益善? #
69143次浏览 332人参与
# AI“智障”时刻 #
23857次浏览 119人参与
# 你觉得实习能学到东西吗 #
134960次浏览 1454人参与
# 第一份工作应该只看薪资吗 #
233970次浏览 1855人参与
# 电信求职进展汇总 #
39800次浏览 197人参与
# 关于春招你都做了哪些准备? #
125914次浏览 717人参与
# AI求职实录 #
20508次浏览 488人参与
SHEIN希音公司福利 370人发布