pat1035 Password

博客介绍了一个编程任务,要求输入名称和密码,然后将密码中的'1'替换为'@','0'替换为'%','l'替换为'L','o'替换为'O',思路是直接实现该功能,还给出了代码。

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

题意:输入名称和密码,用'@'代替'1',‘%’代替‘0’,‘L’代替‘l’,‘O’代替‘o’。

思路:直接做。

代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAX_N = 1010;
const int MAX_S = 15;
char name[MAX_N][MAX_S], word[MAX_N][MAX_S];
char s1[MAX_S], s2[MAX_S];
int len, n;

bool check(char s[]) {
    int slen = strlen(s);
    bool flag = false;
    for (int i = 0; i < slen; i++) {
        if (s[i] == '1' || s[i] == '0' || s[i] == 'l' || s[i] == 'O') {
            flag = true;
            if (s[i] == '1') s[i] = '@';
            if (s[i] == '0') s[i] = '%';
            if (s[i] == 'l') s[i] = 'L';
            if (s[i] == 'O') s[i] = 'o';
        }
    }
    return flag;
}

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s %s", s1, s2);
        if (check(s2)) {
            strcpy(name[len], s1);
            strcpy(word[len], s2);
            len++;
        }
    }
    if (len == 0) {
        if (n == 1) printf("There is %d account and no account is modified\n", n);
        else printf("There are %d accounts and no account is modified\n", n);
    } else {
        printf("%d\n", len);
        for (int i = 0; i < len; i++) {
            printf("%s %s\n", name[i], word[i]);
        }
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值