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). One solution is to replace 1 (one) by @0 (zero) by %l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N (≤), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.

Output Specification:

For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line There are N accounts and no account is modified where N is the total number of accounts. However, if N is one, you must print There is 1 account and no account is modified instead.

Sample Input 1:

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa

Sample Output 1:

2
Team000002 RLsp%dfa
Team000001 R@spodfa

Sample Input 2:

1
team110 abcdefg332

Sample Output 2:

There is 1 account and no account is modified

Sample Input 3:

2
team110 abcdefg222
team220 abcdefg333

Sample Output 3:

There are 2 accounts and no account is modified
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxnum 100005 bool transs(string& s){
bool flag = true;
for(int i=;i < s.size();i++){
if(s[i] == ''){s[i] = '@';flag = false;}
else if(s[i] == ''){s[i] = '%';flag = false;}
else if(s[i] == 'l'){s[i] = 'L';flag = false;}
else if(s[i] == 'O'){s[i] = 'o';flag = false;}
} return flag;
} int main(){
int n;cin >> n;
vector<vector<string>> vec; //vector不能随便开空间,开了以后就会有默认值,然后你再push-back就加到默认的后面了。
for(int i=;i < n;i++){
string s1,s2;
cin >> s1 >> s2;
vector<string>temp;
temp.push_back(s1);temp.push_back(s2);
vec.push_back(temp);
}
for(int i=;i < vec.size();i++){ //vector 循环中出现erase要注意i的位置会向前,从而跳过了删除的后一个项
if(transs(vec[i][])) {vec.erase(vec.begin()+i);i--;}
}
if(vec.size()){
cout << vec.size() << endl;
for(int i=;i < vec.size();i++){
cout << vec[i][] << " " << vec[i][] << endl;
}
}
else{
if(n == ) cout << "There is 1 account and no account is modified" << endl;
else cout << "There are " << n << " accounts and no account is modified";
} return ;
}

_

vector不能随便开空间,开了以后就会有默认值,然后你再push-back就加到默认的后面了。
vector 循环中出现erase要注意i的位置会向前,从而跳过了删除的后一个项
 

PAT 1035 Password的更多相关文章

  1. PAT 1035 Password [字符串][简单]

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  2. pat 1035 Password(20 分)

    1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...

  3. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  4. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  5. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  6. 浙大pat 1035题解

    1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...

  7. 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  8. 【PAT】1035. Password (20)

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...

  9. PAT 甲级 1035 Password

    https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520 To prepare for PAT, th ...

随机推荐

  1. Jquery相关插件

    jQuery 插件autocomplete 应用 介绍 $("#AccountNames").autocomplete(Accounts, { minChars: 0, match ...

  2. python学习 day011打卡 迭代器

    本节的主要内容: 1.函数名的使用以及第一类对象 2.闭包 3.迭代器 一.函数名的运用. 函数名是一个变量,但它是一个特殊的变量,与括号配合可以执行函数的变量. 1.函数名的内存地址 def fun ...

  3. 接口自动化python

    !/usr/bin/env python coding=utf-8 Todo:接口自动化测试 Author:归根落叶 Blog:http://this.ispenn.com import json i ...

  4. IntelliJ IDEA Tomcat中端口被占用的问题

    早上来公司,新建了一个项目,启动Tomcat,报错,如图所示 端口1099被占用 cmd——netstat -aon|findstr 1099 此时出现了一个问题,输入:netstat -an,提示: ...

  5. php格式化数字输出number_format

    <?php $num = 4999.944444; $formattedNum = number_format($num).PHP_EOL; echo $formattedNum; $forma ...

  6. Java的CountDownLatch和CyclicBarrier的理解和区别

    CountDownLatch和CyclicBarrier的功能看起来很相似,不易区分,有一种谜之的神秘.本文将通过通俗的例子并结合代码讲解两者的使用方法和区别. CountDownLatch和Cycl ...

  7. STL_string.vector中find到的iterator的序号

    ZC:注意,printf("0x%08X\n",vtr.end()); 打印出来 应该就是 0x00000000,∵ 它就是 指向最后一个元素的后面,应该是理解成 无意义      ...

  8. Git Gui 常见错误

  9. U8工具栏特别小是怎么回事

    用友的工具栏特别窄了,填制凭证里的保存.增加凭证等按钮因为工具栏特别窄都看不清了 解决方法:正常机器下的system32下面的mscomctl.ocx文件替换到有问题的机器下,您的系统应该是XP的,这 ...

  10. CSS段落对齐方式

    CSS段落对齐有两种方式:水平对齐和垂直对齐. 1.水平对齐: (1).text-align:left;         //左对齐 (2).text-align:right;      //右对齐 ...