1035 Password (20 分)(字符串)

注意下单复数

#include<bits/stdc++.h>

using namespace std;
pair<string,string>pa;
int main()
{
    int n;
    scanf("%d",&n);

    vector<pair<string,string> >vec;
    for(int i=0;i<n;i++){
        char a[20],b[20];
        scanf("%s %s",a,b);
        bool flag=false;
        for(int j=0;b[j];j++){
            if(b[j]==‘l‘){
                b[j]=‘L‘;
                flag=true;
            }
            else if(b[j]==‘1‘){
                b[j]=‘@‘;
                flag=true;
            }
            else if(b[j]==‘0‘){
                b[j]=‘%‘;
                flag=true;
            }
            else if(b[j]==‘O‘){
                b[j]=‘o‘;
                flag=true;
            }
        }
        if(flag) vec.push_back(make_pair(a,b));
    }
    if(vec.size()==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",vec.size());
        for(int i=0;i<vec.size();i++){
            cout<<vec[i].first<<" "<<vec[i].second<<endl;
        }
    }
    return 0;
}

其实没必要用vector<pari<string,string>> 直接用vector<string> 即可 把空格也当成字符串放在一个字符串里

原文地址:https://www.cnblogs.com/chenchen-12/p/10392287.html

时间: 2024-08-30 11:53:09

1035 Password (20 分)(字符串)的相关文章

PAT甲级——1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase)

PAT Advanced 1035 Password (20分)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase)

PAT 1035. Password (20)

1035. Password (20) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

1035 Password (20)

1 #include <stdio.h> 2 #include <string.h> 3 struct MyStruct 4 { 5 char ID[11]; 6 char Password[11]; 7 bool changed; 8 }; 9 int main() 10 { 11 int n,i,j; 12 MyStruct User[1001]; 13 while(scanf("%d",&n)!=EOF) 14 { 15 for(i=0;i<

PAT甲题题解-1035. Password (20)-水

题意:给n个用户名和密码,把密码中的1改为@,0改为%,l改为L,O改为o. 让你输出需要修改密码的用户名个数,以及对应的用户名和密码,按输入的顺序.如果没有用户需要修改,则输出对应的语句,注意单复数... 没啥好说的,就for一遍密码,把需要改的改下,存入到ans中去. #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <cm

PAT:1035. Password (20) AC

#include<stdio.h> #include<string.h> typedef struct STU { char mID[15]; char mpass[15]; bool tag; }STU; STU arr[1010]; int main() { memset(arr,0,sizeof(arr)); int n,change=0; scanf("%d",&n); for(int i=0 ; i<n ; ++i) { scanf(&q

pat1035. Password (20)

1035. Password (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is

1035. Password

1035. Password (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is

pat 1035 Password(20 分)

1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

A1035 Password (20)(20 分)

A1035 Password (20)(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zer