-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPassword.cpp
87 lines (83 loc) · 1.57 KB
/
Password.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <string>
struct students
{
std::string name, password;
};
bool modify(std::string &s)
{
int length = s.size();
int flag = 0;
for (int i = 0; i < length; i++)
{
if (s[i] == '1')
{
s.replace(i, 1, "@");
flag = 1;
}
else if (s[i] == '0')
{
s.replace(i, 1, "%");
flag = 1;
}
else if (s[i] == 'l')
{
s.replace(i, 1, "L");
flag = 1;
}
else if (s[i] == 'O')
{
s.replace(i, 1, "o");
flag = 1;
}
}
if (flag == 0)
{
return false;
}
else
{
return true;
}
}
int main()
{
int n;
std::cin >> n;
students *s = new students[n];
for (int i = 0; i < n; i++)
{
std::cin >> s[i].name >> s[i].password;
}
int visited[1000] = {-1};
int j = 0;
for (int i = 0; i < n; i++)
{
int flag = modify(s[i].password);
if (flag)
{
visited[j] = i;
j++;
}
}
if (j == 0)
{
if (n > 1)
{
std::cout << "There are " << n << " accounts and no account is modified";
}
else
{
std::cout << "There is " << n << " account and no account is modified";
}
}
else
{
std::cout << j << std::endl;
for (int i = 0; i < j; i++)
{
std::cout << s[visited[i]].name << " " << s[visited[i]].password << std::endl;
}
}
return 0;
}