题目
思路
依次处理每个字符串的每个字符,判断需不需要修改就可以了;
注意,最后输出的时候会有单复数的情况,is 和 are,是不是复数;
代码
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n, m = 0;
vector<string> names, pwds;
string name, pwd;
scanf("%d", &n);
for(int i = 0; i < n; i ++){
cin >> name >> pwd;
bool flag = false;
for(int i = 0; i < pwd.size(); i ++){
if(pwd[i] == 'l') pwd[i] = 'L', flag = true;
else if(pwd[i] == 'O') pwd[i] = 'o', flag = true;
else if(pwd[i] == '1') pwd[i] = '@', flag = true;
else if(pwd[i] == '0') pwd[i] = '%', flag = true;
}
if(flag){
names.push_back(name), pwds.push_back(pwd);
m ++;
}
}
if(m == 0) {
if(n == 1) printf("There is 1 account and no account is modified\n");
else printf("There are %d accounts and no account is modified\n", n);
}
else{
printf("%d\n", m);
for(int i = 0; i < m; i ++){
cout << names[i] << " " << pwds[i] << endl;
}
}
system("pause");
return 0;
}