【1035 20 字符串】 Password
传送门
题意
给定 \(n\) ,然后给定 \(n\) 组账号密码,将密码中的特殊字符替换替换规则如下
- \(1 \sim @\)
- \(0 \sim \%\)
- \(l \sim L\)
- $O \sim o $
如果修改过,将修改过的账号密码输出,如果没修改过输出特定的字符串
数据范围
\(n\leq 1000\)
题解
- 读题不仔细容易忽略的两个点
- 只修改一个时,英文要用单数形式
- 只需对密码做修改,账号不做修改
Code
#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
int m = 0;
vector<pair<string, string>> ans;
for (int i = 0; i < n; i++) {
string name, pwd; cin >> name >> pwd;
bool modify = 0;
for (int j = 0; j < pwd.size(); j++) {
if (pwd[j] == '1') pwd[j] = '@', modify = 1;
if (pwd[j] == 'l') pwd[j] = 'L', modify = 1;
if (pwd[j] == '0') pwd[j] = '%', modify = 1;
if (pwd[j] == 'O') pwd[j] = 'o', modify = 1;
}
if (modify) ans.push_back({name, pwd});
}
if (not ans.size()) {
if (n == 1) cout << "There is " << n << " account and no account is modified";
else cout << "There are " << n << " accounts and no account is modified";
} else {
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++) {
if (i) cout << endl;
cout << ans[i].first << ' ' << ans[i].second;
}
}
}

浙公网安备 33010602011771号