zoukankan      html  css  js  c++  java
  • PAT甲题题解-1035. Password (20)-水

    题意:
    给n个用户名和密码,把密码中的1改为@,0改为%,l改为L,O改为o。

    让你输出需要修改密码的用户名个数,以及对应的用户名和密码,按输入的顺序。
    如果没有用户需要修改,则输出对应的语句,注意单复数。。。

    没啥好说的,就for一遍密码,把需要改的改下,存入到ans中去。

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <string.h>
    #include <cmath>
    using namespace std;
    const int maxn=1000+5;
    struct Node{
        char team[15];
        char pass[15];
    }ans[maxn];
    int main()
    {
        int n;
        int cnt=0;
        char team[20],pass[20];
        scanf("%d",&n);
        bool flag;
        for(int i=0;i<n;i++){
            scanf("%s %s",team,pass);
            flag=true;
            int len=strlen(pass);
            for(int j=0;j<len;j++){
    //printf("%c
    ",pass[j]);
                if(pass[j]=='1'){
    //printf("1->@
    ");
                    flag=false;
                    pass[j]='@';
                }
                else if(pass[j]=='0'){
    //printf("0->\%
    ");
                    flag=false;
                    pass[j]='%';
                }
                else if(pass[j]=='l'){
    //printf("l->L
    ");
                    flag=false;
                    pass[j]='L';
                }
                else if(pass[j]=='O'){
    //printf("O->o
    ");
                    flag=false;
                    pass[j]='o';
                }
            }
            if(!flag){
                strcpy(ans[cnt].team,team);
                strcpy(ans[cnt].pass,pass);
                cnt++;
            }
        }
        if(cnt==0){
            if(n==1)
                printf("There is %d account and no account is modified
    ",n);
            else
                printf("There are %d accounts and no account is modified
    ",n);
        }
        else{
            printf("%d
    ",cnt);
            for(int i=0;i<cnt;i++){
                printf("%s %s
    ",ans[i].team,ans[i].pass);
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    树莓派也跑Docker和.NET Core
    使用iSCSI协议挂载网络磁盘,电脑瞬间扩大一个T的容量!
    Azure DevOps Server (TFS)免费吗?
    明确架构目标
    MMN实用架构过程概览
    设计恰如其分的架构
    对象的自治和行为的扩展与适配
    Message Chains与Fluent Interface
    如何减少代码的量
    《软件框架设计的艺术》书评
  • 原文地址:https://www.cnblogs.com/chenxiwenruo/p/6786509.html
Copyright © 2011-2022 走看看