#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define N 15
typedef struct {
char name[N], password[N];
} account;
bool check(account *a, account *a2) {
int i, length;
char tmp[N];
bool flag = false;
length = strlen(a->password);
for (i = 0; i < length; i++) {
switch (a->password[i]) {
case '1': flag = true; tmp[i] = '@'; break;
case '0': flag = true; tmp[i] = '%'; break;
case 'l': flag = true; tmp[i] = 'L'; break;
case 'O': flag = true; tmp[i] = 'o'; break;
default: tmp[i] = a->password[i]; break;
}
}
tmp[i] = '\0';
if (flag) {
strcpy(a2->name, a->name);
strcpy(a2->password, tmp);
return true;
}
else {
return false;
}
}
int main(void) {
int n, m = 0, i;
account *a, *a2;
scanf("%d", &n);
a = (account *)calloc(n, sizeof(account));
a2 = (account *)calloc(n, sizeof(account));
for (i = 0; i < n; i++) {
scanf("%s %s", a[i].name, a[i].password);
if (check(a + i, a2 + m)) {
m++;
}
}
if (m == 0 && n == 1) {
puts("There is 1 account and no account is modified");
}
else if (m == 0) {
printf("There are %d accounts and no account is modified\n", n);
}
else {
printf("%d\n", m);
for (i = 0; i < m; i++) {
printf("%s %s\n", a2[i].name, a2[i].password);
}
}
free(a);
free(a2);
return 0;
}
1035. Password (20)解题报告
最新推荐文章于 2022-02-25 20:00:37 发布