原题链接:https://pintia.cn/problem-sets/994805342720868352/exam/problems/type/7?problemSetProblemId=994805454989803520&page=0
坑点:
输出格式需要多加注意:
1. M是否需要输出。当为0时不需要输出M
2.区分 “is” 和 “are” ,“account” 和 “accounts”
代码:(C++)
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
#define endl '\n'
int N;
vector<pair<string, string> > v;
bool modify[1010];
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//input
cin >> N;
for (int i = 0; i < N; i++) {
string name, password;
cin >> name >> password;
v.emplace_back(make_pair(name,password));
}
int M = 0;
for (int i = 0; i < v.size(); i++) {
string password = v[i].second;
bool flag = false;
for (int i = 0; i < password.size(); i++) {
if (password[i] == '1') {
password[i] = '@';
flag = true;
}
if (password[i] == 'l') {
password[i] = 'L';
flag = true;
}
if (password[i] == '0') {
password[i] = '%';
flag = true;
}
if (password[i] == 'O') {
password[i] = 'o';
flag = true;
}
}
v[i].second = password;
if (flag) {
modify[i] = true;
M++;
}
}
//output
if (M == 0) {
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 << M << endl;
for (int i = 0; i < v.size(); i++) {
if (modify [i] ) {
cout << v[i].first << " " << v[i].second << endl;
}
}
}
return 0;
}