PAT甲级1035字符串

#include
using namespace std;
int main(){
    int n;
    vector<string> v;
    cin>>n;
    for(int i=0;i<n;i++){//注意这里不能用while(n--),因为后面还会用到n
        string name,account;
        int flag=0;
        cin>>name>>account;
        for(int i=0;i<account.size();i++){
            if(account[i]=='1'){
                account[i]='@';
                flag=1;
            }
            if(account[i]=='0'){
                account[i]='%';
                flag=1;
            }
            if(account[i]=='l'){
                account[i]='L';
                flag=1;
            }
            if(account[i]=='O'){
                account[i]='o';
                flag=1;
            }
        }
        if(flag){
            string temp=name+" "+account;
            v.push_back(temp);
        }
    }

    int cnt=v.size();
    if(cnt!=0){
        printf("%d\n",cnt);
        for(int i=0;i<cnt;i++)
            cout<<v[i]<<endl;
    }
    else if(n==1){
        printf("There is 1 account and no account is modified");
    }
    else{
        printf("There are %d accounts and no account is modified", n);
    }
    return 0;
}

你可能感兴趣的:(PAT甲级)