RT
https://i.loli.net/2019/08/07/gS95mI8nbZBX4ha.jpg
感谢
1
angelcstt OP 大佬在哪里 求助大佬啊 有偿都可以
|
2
angelcstt OP |
3
msaionyc 2019-08-07 19:38:44 +08:00
你题目给完整了吗
|
5
wateryessence 2019-08-07 19:40:08 +08:00
牛客网问去
|
6
angelcstt OP 第一题 @msaionyc ~
https://i.loli.net (外链)/2019/08/07/gS95mI8nbZBX4ha.jpg https://imgchr.com/i/eII5 (外链) GT |
7
lxy42 2019-08-07 19:50:32 +08:00 via Android
第一题没拍全吧,估计考查的是中缀后缀表达式。
|
9
brainfxxk 2019-08-07 20:10:22 +08:00
第一个表达式求值 第二个字符串处理...
|
10
lxy42 2019-08-07 20:46:36 +08:00 via Android
第二题用一个长度为 26 的数组表示字符集,数组元素值等于对应字符的个数。两个数组相减就是结果。
|
11
Leigg 2019-08-07 21:02:54 +08:00 via Android
能不能换个图床,这个很渣
|
14
wangkai0351 2019-08-07 21:11:29 +08:00
#include <iostream>
#include <string> #include <map> #include <vector> #include <sstream> #include <string.h> using namespace std; vector<string> split(const string &str,const string &pattern) { //const char* convert to char* char * strc = new char[strlen(str.c_str())+1]; strcpy(strc, str.c_str()); vector<string> resultVec; char* tmpStr = strtok(strc, pattern.c_str()); while (tmpStr != NULL) { resultVec.push_back(string(tmpStr)); tmpStr = strtok(NULL, pattern.c_str()); } delete[] strc; return resultVec; } int main(void) { string s; while(cin>>s) { string s1; string s2; size_t at_pos = s.find('@'); //cout << "at_pos = " << at_pos << endl; if(at_pos == s.size()-1) { for (int i = 0; i < s.size()-1; ++i) { cout << s[i]; } cout << endl; break; } else { s1 = s.substr(0,at_pos); s2 = s.substr(at_pos+1,s.size()); //cout << s1 << endl; //cout << s2 << endl; } //分别处理 s1,s2 map<char,int> um1; map<char,int> um2; //s1 按照逗号分割 vector<string> v1; v1 = split(s1,","); for(auto e:v1) { int i; char c; char c_; stringstream ss(e); ss >> c >> c_ >> i; //cout << "c = " << c << " i = " << i << endl; um1[c] = i; } //s2 按照逗号分割 vector<string> v2; v2 = split(s2,","); for(auto e:v2) { int i; char c; char c_; stringstream ss(e); ss >> c >> c_ >> i; //cout << "c = " << c << " i = " << i << endl; um2[c] = i; } string res; for(auto e:um1) { res += e.first; res += ":"; res += to_string(e.second-um2[e.first]); res += ","; } for (int j = 0; j < res.size()-1; ++j) { cout << res[j]; } cout << endl; } return 0; } //a:3,b:5,c:1@ //a:3,b:5,c:2@a:1,b:2 |
15
wangkai0351 2019-08-07 21:22:55 +08:00
|
16
zhoudaiyu 2019-08-07 23:17:04 +08:00
我来发个第一题的,不知道能不能用 Py 实现
def get_result(given_string): return eval((" ".join([items for items in given_string]).replace("1", "True").replace("0", "False").replace("!", "not").replace("&", "and").replace("|", "or"))) |
17
Mountain 2019-08-08 00:28:03 +08:00 via iPhone
公然求助场外观众了?
|
18
summer20100514 2019-08-08 11:17:37 +08:00
完善拉黑列表
|