浙大PAT甲级 1035

本文介绍了一个简单的C++程序,该程序用于读取用户输入的账户名和原始密码,并将特定字符进行替换,例如数字1替换为@,数字0替换为%,小写字母l替换为大写字母L等。程序统计了修改过的密码数量并输出了修改后的账户信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

简单的字符串题目。

AC代码:

#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<list>
#define inf 10000000
using namespace std;
int mark[1005];
struct node
{
    string name;
    string passw;
};
vector<node> v;
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        node tmp;
        cin>>tmp.name>>tmp.passw;
        v.push_back(tmp);
    }
    int ans=0;
    for(int i=0;i<v.size();i++)
    {
        int flag=0;
        for(int j=0;j<v[i].passw.size();j++)
        {
            if(v[i].passw[j]=='1')
            {
                v[i].passw[j]='@';
                flag=1;
            }
            else if(v[i].passw[j]=='0')
            {
                v[i].passw[j]='%';
                flag=1;
            }
            else if(v[i].passw[j]=='l')
            {
                v[i].passw[j]='L';
                flag=1;
            }
            else if(v[i].passw[j]=='O')
            {
                v[i].passw[j]='o';
                flag=1;
            }
        }
        if(flag==1)
            ans++;
        else
        {
            mark[i]=1;
        }
    }
    if(n==1&&ans==0)
    {
        cout<<"There is 1 account and no account is modified";
    }
    else if(n>1&&ans==0)
    {
        cout<<"There are ";
        cout<<n;
        cout<<" accounts and no account is modified";
    }
    else
    {
        cout<<ans<<endl;
        for(int i=0;i<v.size();i++)
        {
            if(mark[i]==0)
            {
                cout<<v[i].name<<" "<<v[i].passw<<endl;
            }
        }
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值