AcWing 刷题记录 1519.密码

AcWing 刷题记录 1519.密码

在这里插入图片描述

思路

每输入一组数据,进行更改密码字符串,之后比较原密码与修改之后的密码是否相等,不相等记录加一。

代码

#include<iostream>
using namespace std;

const int N = 1010;

string changed_name[N],changed_pwd[N];

// 修改字符串函数
string change(string pwd)
{
    string res;
    for(auto c:pwd)
    {
        if(c == '1')
        {
            res = res + '@';
        }
        else if(c == '0')
        {
            res = res + '%';
        }
        else if(c == 'l')
        {
            res = res + 'L';
        }
        else if(c == 'O')
        {
            res = res + 'o';
        }
        else
        {
            res =  res + c;
        }
    }
    return res;
}


int main()
{
    int m;
    cin>>m;
    
    string cur_name,cur_pwd;
    int count = 0;
    
    for(int i = 0; i < m; i++)
    {
        cin>>cur_name>>cur_pwd;
        string changePwd = change(cur_pwd);
        if(changePwd != cur_pwd)
        {
            // 记录修改的id以及字符串
            changed_name[count] = cur_name;
            changed_pwd[count] = changePwd;
            count++;
        }
    }
    
    if(count == 0)
    {
        if(m == 1)
        {
            cout<<"There is 1 account and no account is modified"<<endl;
        }
        else
        {
            printf("There are %d accounts and no account is modified",m);
        }
    }
    else
    {
        cout<<count<<endl;
        for(int i = 0; i < count; i++)
        {
            cout<<changed_name[i]<<' '<<changed_pwd[i]<<endl;
        }
    }
    
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

少写代码少看论文多多睡觉

求打赏,求关注,求点赞

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值