PAT 1035. Password

本文介绍了一个PAT-A级别编程题目1035的解答过程,该题要求对输入的账号密码进行特定字符替换,并输出替换后的结果及统计信息。文章通过C++代码实现了解题思路,利用标准库函数完成字符串操作。

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

https://www.patest.cn/contests/pat-a-practise/1035
纯模拟 做做水题 陶冶情操 反正我也不会做难题了 = =

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    scanf("%d\n", &N);
    vector<pair<string, string> > ans;
    for (int i = 0; i < N; i++) {
        string accout, pwd;
        cin >> accout >> pwd;
        bool flag = true;
        for (int i = 0; i < pwd.size(); i++) {
            if (pwd[i] == '1') pwd[i] = '@', flag = false; else
            if (pwd[i] == '0') pwd[i] = '%', flag = false; else
            if (pwd[i] == 'l') pwd[i] = 'L', flag = false; else
            if (pwd[i] == 'O') pwd[i] = 'o', flag = false;
        }
        if (!flag) {
            ans.push_back(make_pair(accout, pwd));
        }
    }
    if (ans.size() == 0) {
        if (N == 1) {
            cout << "There is 1 account and no account is modified" << endl;
        } else
        cout << "There are " << N << " accounts and no account is modified" << endl;
    } else {
        cout << ans.size() << endl;
        for (auto e : ans) {
            cout << e.first << ' ' << e.second << endl;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值