求助dalao

P4470 [BJWC2018] 售票

@[黑猫_琉璃](/space/show?uid=83985) 其实此题有一个很好用的命令:strncmp,可以直接比较两个字符串的前n位
by love_for_ever @ 2018-08-23 14:18:29


打那么长的代码无聊不 暴力就能ac
by love_for_ever @ 2018-08-24 01:03:27


来一波~ ```cpp #include <iostream> #include<string> using namespace std; string str[53]; string current,keyboard="********************************"; short int n; int main() { cout << keyboard.length(); cin >> n; for (int i = 1; i <= n; i++) cin >> str[i]; cin >> current; int len = current.length(); for (int i = 1; i <= n; i++) if (str[i].find(current) == 0) if (str[i].length() > len) { char open = str[i][len]; keyboard[open - 'A' + 3] = open; } for (int j = 0; j <= 3; j++) cout << keyboard.substr(j * 8, 8) << endl; return 0; } ```
by yubing_lml @ 2019-08-28 09:49:50


@[yubing_lml](/space/show?uid=237242) 这里要注意find()和find_first_of()的用法哇,前车之鉴
by yubing_lml @ 2019-08-28 09:51:03


@[yubing_lml](/space/show?uid=237242) 为啥我@自己是蓝的?难道我还没有绿的资格?
by yubing_lml @ 2019-08-28 09:52:20


|