PAT甲级1035题(密码)


1.题目介绍

1035

2.考察点,难度

字符串处理类,string的遍历,string个别位置替换,难度易

3.解题代码

#include <bits/stdc++.h>
using namespace std;


int main(){
    freopen("D:\\PAT\\Clion\\in.txt","r",stdin);
    int N,sum=0,flag=0;
    cin>>N;
    vector<string> va,vb;
    for(int i=0;i<N;i++){
        string a,b;
        cin>>a>>b;
        for(int j=0;j<b.length();j++){
            if(b[j]=='1')  {
                b[j]='@',flag=1;
            }
            if(b[j]=='0')  {
                b[j]='%',flag=1;
            }
            if(b[j]=='l')  {
                b[j]='L',flag=1;
            }
            if(b[j]=='O')  {
                b[j]='o',flag=1;
            }
        }
        if(flag){
            va.push_back(a);
            vb.push_back(b);
            sum++;
            flag=0;
        }
    }
    if(!sum) N==1?cout<<"There is 1 account and no account is modified"<<endl:cout<<"There are "<<N<<" accounts and no account is modified"<<endl;
    else{
        cout<<sum<<endl;
        for(int i=0;i<va.size();i++){
            cout<<va[i]<<" "<<vb[i]<<endl;
        }
    }
    return 0;
}

4.原题地址

https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520


文章作者: Peyton
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Peyton !
  目录