首页 > 代码库 > PAT1035 Password

PAT1035 Password

题目:PAT1035

 

题解:感觉自己写的这道题有点麻烦,srting还是不太会用,但是挺好用的

 

代码:

  

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<cstring>
 4 #define maxn 1005
 5 using namespace std;
 6 
 7 string user[maxn],pass[maxn];
 8 bool f,f1[maxn];
 9 int n,cou;
10 
11 int main()
12 {
13     cin>>n;
14     for(int i=1;i<=n;i++)
15        cin>>user[i]>>pass[i];
16 
17     f=true;
18     memset(f1,true,n);
19     cou=0;
20 
21     if(n==1) printf("There is 1 account and no account is modified");
22     else
23     {
24         for(int i=1;i<=n;i++)
25         {
26             for(int j=0;j<pass[i].size();j++)
27             {
28                 if(pass[i][j]==1) {pass[i][j]=@;f1[i]=false;f=false;}
29                 else if(pass[i][j]==0) {pass[i][j]=%;f1[i]=false;f=false;}
30                 else if(pass[i][j]==l) {pass[i][j]=L;f1[i]=false;f=false;}
31                 else if(pass[i][j]==O) {pass[i][j]=o;f1[i]=false;f=false;}
32             }
33             if(!f1[i]) cou++;
34         }
35 
36         if(f) printf("There are %d accounts and no account is modified",n);
37         else
38         {
39             printf("%d\n",cou);
40             for(int i=1;i<=n;i++)
41             {
42                 if(!f1[i]) cout<<user[i]<<" "<<pass[i]<<endl;
43             }
44         }
45     }
46     return 0;
47 }

 

PAT1035 Password