PAT 1035

题目 : Password

分值 : 20
难度 : 水题
思路 : 读入一一存起来,然后替换一下,没有替换之后就不输出
坑点 : 没有替换情况下,输出的东西还分 N==1 和 N>1
评语 : 细心就好

具体代码如下

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
#include <iostream>
#include <string>
using namespace std ;
#define L(i,N,K) for(int i=0 ; i< N ;i+=K)
typedef struct Node{
string name ;
string pass ;
bool flag ;
}Nodes ;
Nodes data[1001] ;
void judge(int x)
{
string temp = data[x].pass;
L(i,temp.length(),1)
{
if( data[x].pass[i] == '1')
{
data[x].pass[i] ='@' ;data[x].flag=true ;
}
if( data[x].pass[i] == '0')
{
data[x].pass[i] ='%' ;data[x].flag=true ;
}
if( data[x].pass[i] == 'l')
{
data[x].pass[i] ='L' ;data[x].flag=true ;
}
if( data[x].pass[i] == 'O')
{
data[x].pass[i] ='o' ;data[x].flag=true ;
}
}
}
int main() {
int N ;
cin>> N ;
L(i,N,1)
{
cin>>data[i].name>>data[i].pass ;
data[i].flag = false ;
}
int count = 0 ;
L(i,N,1)
{
judge(i) ;
if(data[i].flag)
count++ ;
}
if(!count)
{
if(N>1)
printf("There are %d accounts and no account is modified\n",N) ;
else if(N==1)
printf("There is 1 account and no account is modified") ;
}
else
{
cout << count <<endl ;
L(i,N,1)
{
if(data[i].flag)
cout << data[i].name <<" "<<data[i].pass<<endl ;
}
}
return 0 ;
}