求虎牙今晚前两题的Ac代码

求虎牙今晚前两题的Ac代码#笔试题目#
全部评论
#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; } }
点赞 回复
分享
发布于 2019-03-26 21:58
请问你投的什么岗
点赞 回复
分享
发布于 2019-03-26 21:25
滴滴
校招火热招聘中
官网直投
这 代码怎么AC啊 不是在白板写吗
点赞 回复
分享
发布于 2019-03-26 21:28
岗位不同 代码不一样
点赞 回复
分享
发布于 2019-03-26 21:32
c++后台开发 A卷
点赞 回复
分享
发布于 2019-03-26 21:33
第一题好像是剑指offer原题,考完才发现。。
点赞 回复
分享
发布于 2019-03-26 21:35
一直ac不了,数据溢出输出什么呀
点赞 回复
分享
发布于 2019-03-26 21:40
代码不是在白板上写的嘛。。。
点赞 回复
分享
发布于 2019-03-26 21:51
不是问答题吗
点赞 回复
分享
发布于 2019-03-26 22:35

相关推荐

投递美团等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务