PAT1035 Password

题目:PAT1035

题解:感觉自己写的这道题有点麻烦,srting还是不太会用,但是挺好用的

代码:

  

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<cstring>
 4 #define maxn 1005
 5 using namespace std;
 6
 7 string user[maxn],pass[maxn];
 8 bool f,f1[maxn];
 9 int n,cou;
10
11 int main()
12 {
13     cin>>n;
14     for(int i=1;i<=n;i++)
15        cin>>user[i]>>pass[i];
16
17     f=true;
18     memset(f1,true,n);
19     cou=0;
20
21     if(n==1) printf("There is 1 account and no account is modified");
22     else
23     {
24         for(int i=1;i<=n;i++)
25         {
26             for(int j=0;j<pass[i].size();j++)
27             {
28                 if(pass[i][j]==‘1‘) {pass[i][j]=‘@‘;f1[i]=false;f=false;}
29                 else if(pass[i][j]==‘0‘) {pass[i][j]=‘%‘;f1[i]=false;f=false;}
30                 else if(pass[i][j]==‘l‘) {pass[i][j]=‘L‘;f1[i]=false;f=false;}
31                 else if(pass[i][j]==‘O‘) {pass[i][j]=‘o‘;f1[i]=false;f=false;}
32             }
33             if(!f1[i]) cou++;
34         }
35
36         if(f) printf("There are %d accounts and no account is modified",n);
37         else
38         {
39             printf("%d\n",cou);
40             for(int i=1;i<=n;i++)
41             {
42                 if(!f1[i]) cout<<user[i]<<" "<<pass[i]<<endl;
43             }
44         }
45     }
46     return 0;
47 }
时间: 2024-12-21 14:18:50

PAT1035 Password的相关文章

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

输入password登录到主界面,录入学生编号,排序后输出

n 题目:输入password登录到主界面,录入学生编号,排序后输出 n 1.  语言和环境 A.实现语言 C语言 B.环境要求 VC++ 6.0 n 2.  要求 请编写一个C语言程序.将若干学生编号按字母顺序(由小到大)输出. 程序的功能要求例如以下: 1)  输入password"admin",正确则进入主界面,错误则直接推出(exit(0)): 2)从键盘输入5个学生编号"BJS1001","BJS2001"."BJS1011&

关于JavaEE项目连接数据库提示 Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)的解决方案

最近这三天,都在解决如下的问题:我MyEclipse中的JavaEE工程,运行之后就提示Access denied for user 'root'@'localhost' (using password: YES),当我用一个Java文件连接MySQL数据库时,没有任何问题.于是我在网上找了一些解决方案: (1)让root给当前用户授予增删改查的权限:grant select,insert,update,delete on *.* to 用户名@"%" Identified by &q

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password October 11, 2014 by sharad chhetri 4 Comments In this post we will learn, how to reset / recover forgotten root password on CentOS 7 / RHEL 7 (Red Hat Enterprise Linux 7). On RHEL 5/6 or Cen

Reset root password in CentOS 7 / RHEL 7

There may be some occasion you will end up with requirement to reset the root password, the occasion comes when you forget root password; follow this guide to reset the password of root. In CentOS, single user mode will help us to achieve our goal of

How To Reset Your Forgotten Root Password On CentOS 7 Servers

Sometimes you forget stuff. I do. I forget important passwords for important websites sometimes. Retrieving your forgotten passwords for most websites is easy, all one has to do remember few details that were used when signing up for the service to g

#1045 - Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)

如上所示,当我们修改数据库的密码之后,再次进入phpmyadmin的时候,就会产生这种错误#1045 - Access denied for user 'root'@'localhost' (using password: NO) .那这种错误产生的原因是什么呢?解释就是,密码修改后,新旧密码不一致产生的.改正过来其实也很简单,在phpmyadmin3.4.10.1文件夹下找到config.inc.php这个文件,然后找到里面$cfg['Servers'][$i]['password'] = '

RHEL7 recover reset root password

If you have lost or forgot root password of RHEL7, you can follow this step to change to a new password, this is different with the RHEL6  single-usermode, 1, press e button in GRUB 2 boot screen. 2, at the end of Linux line add init=/bin/sh and remo

uva 1076 - Password Suspects(AC自动机+记忆化搜索)

题目链接:uva 1076 - Password Suspects 题目大意:有一个长度为n的密码,存在m个子串,问说有多少种字符串满足,如果满足个数不大于42,按照字典序输出. 解题思路:根据子串构建AC自动机,然后记忆化搜索,dp[i][u][s]表示第i个字符,在u节点,匹配s个子串. #include <cstdio> #include <cstring> #include <queue> #include <string> #include <