给迅雷编程题跪了

编程题的输入情况要怎么处理?
全部评论
#include<iostream> #include<string> #include<vector> #include<map> using namespace std; int find(const vector<int> &arr) { int result = 0; for (size_t i = 0; i < arr.size(); ++i) { result += arr[i]; if (result >= 10) result %= 10; } return result; } int main(void) { string str; vector<int> arr; map<string, int> times; int result = 0; cin >> str; for (size_t i = 0; i < str.length(); ++i) { int j = i; int t = 0; if (str[j] == ',') continue; while (str[j] != ',' && j < str.size()) { ++j; ++t; } string sub = str.substr(i, t); if (sub == "A") { arr.push_back(1); ++times[sub]; } else if (sub == "J" || sub == "Q" || sub == "K" || sub == "10") { arr.push_back(10); ++times[sub]; } else if (sub == "2" || sub == "3" || sub == "4" || sub == "5" || sub == "6" || sub == "7" || sub == "8" || sub == "9") { arr.push_back(atoi(sub.c_str())); ++times[sub]; } else { cout << "none" << endl; return 0; } } auto it = times.begin(); while (it != times.end()) { if (it->second > 4) { cout << "none" << endl; return 0; } ++it; } if (arr.size() != 5) { cout << "none" << endl; return 0; } result = find(arr); if (result) cout << result << endl; else cout << "none" << endl; return 0; }
点赞 回复 分享
发布于 2016-09-19 22:10
是一个数去掉数字那个吗? 那个题目如果是10000去掉2个,答案是0还是100呢
点赞 回复 分享
发布于 2016-09-19 21:44
有编程题吗?你们考一个还是两个小时
点赞 回复 分享
发布于 2016-09-19 21:32
我也是。。。输入不好处理
点赞 回复 分享
发布于 2016-09-19 21:29
对啊,第一题通过率0%,找不到错误原因。。
点赞 回复 分享
发布于 2016-09-19 21:09

相关推荐

评论
点赞
收藏
分享

创作者周榜

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