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

相关推荐

08-19 18:59
已编辑
绍兴文理学院 Java
一只末影酱:一、1w+qps嘛感觉数据有点太夸张了 二、还有就是99.95%这些,本身大部分学生做的小项目基本是100%,因为量太小了,网络抖动问题也基本模拟不出来,感觉这些不太好写 三、你这些项目,都是一个月就做完了,更抽象了,也就是大概意味着,没有技术调研,没有上线测试,
点赞 评论 收藏
分享
09-01 21:40
已编辑
同济大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务