题意:输入名称和密码,用'@'代替'1',‘%’代替‘0’,‘L’代替‘l’,‘O’代替‘o’。
思路:直接做。
代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAX_N = 1010;
const int MAX_S = 15;
char name[MAX_N][MAX_S], word[MAX_N][MAX_S];
char s1[MAX_S], s2[MAX_S];
int len, n;
bool check(char s[]) {
int slen = strlen(s);
bool flag = false;
for (int i = 0; i < slen; i++) {
if (s[i] == '1' || s[i] == '0' || s[i] == 'l' || s[i] == 'O') {
flag = true;
if (s[i] == '1') s[i] = '@';
if (s[i] == '0') s[i] = '%';
if (s[i] == 'l') s[i] = 'L';
if (s[i] == 'O') s[i] = 'o';
}
}
return flag;
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s %s", s1, s2);
if (check(s2)) {
strcpy(name[len], s1);
strcpy(word[len], s2);
len++;
}
}
if (len == 0) {
if (n == 1) printf("There is %d account and no account is modified\n", n);
else printf("There are %d accounts and no account is modified\n", n);
} else {
printf("%d\n", len);
for (int i = 0; i < len; i++) {
printf("%s %s\n", name[i], word[i]);
}
}
return 0;
}