阿里模拟笔试编程题,英文就好做多了
#include <bits/stdc++.h> using namespace std; int main() { string expression; string userquery; cin >> expression >> userquery; for (decltype(expression.size()) i = 0; i < expression.size(); i++) { if (expression[i] == '<') { expression[i] = '('; } else if (expression[i] == '>') { expression[i] = ')'; } if (expression[i] == '[') { expression[i] = '('; } else if (expression[i] == ']') { expression.insert(i, ")?"); expression.erase(i + 2, 1); } if (expression[i] == '@') { expression.erase(i, 9); expression.insert(i, "(.+)"); } } regex re(expression); bool ret = regex_match(userquery, re); cout << expression << endl; cout << ret << endl; return 0; }
#阿里巴巴##笔试题目#