HDU 1039.Easier Done Than Said?【字符串处理】【8月24】
来源:互联网 发布:mac双系统卸载win7 编辑:程序博客网 时间:2024/04/30 04:32
Easier Done Than Said?
Problem Description
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that are relatively secure but still easy to remember.
FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:
It must contain at least one vowel.
It cannot contain three consecutive vowels or three consecutive consonants.
It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.
(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.
FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:
It must contain at least one vowel.
It cannot contain three consecutive vowels or three consecutive consonants.
It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.
(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.
Input
The input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.
Output
For each password, output whether or not it is acceptable, using the precise format shown in the example.
Sample Input
atvptouibontreszoggaxwiinqeephouctuhend
Sample Output
<a> is acceptable.<tv> is not acceptable.<ptoui> is not acceptable.<bontres> is not acceptable.<zoggax> is not acceptable.<wiinq> is not acceptable.<eep> is acceptable.<houctuh> is acceptable.
1:有元音字母
2:不能三个连续元音或辅音
3:不能连续两个相同的字母,除非ee或oo
直接判断。代码如下:#include<cstdio>#include<cstring>int yuanfu[27]={0};bool yuan(char s[]){//判断有无元音字字母 for(int i=0;i<strlen(s);i++) if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u') return true; return false;}bool sanlian(char s[]){//判断有无三个连续的元音或辅音字母 if(strlen(s)<3) return true; for(int i=0;i<strlen(s)-2;i++) if(yuanfu[s[i]-'a']==yuanfu[s[i+1]-'a']&&yuanfu[s[i+1]-'a']==yuanfu[s[i+2]-'a']) return false; return true;}bool erlian(char s[]){//判断有无两个连续相同非ee或oo字母 if(strlen(s)<2) return true; for(int i=0;i<strlen(s)-1;i++) if(s[i]==s[i+1]&&!(s[i]=='e'||s[i]=='o')) return false; return true;}int main(){ char s[110]; yuanfu[0]=yuanfu[4]=yuanfu[8]=yuanfu[14]=yuanfu[20]=1; while(scanf("%s",s)!=EOF&&strcmp(s,"end")){ if(!yuan(s)) printf("<%s> is not acceptable.\n",s); else if(!sanlian(s)) printf("<%s> is not acceptable.\n",s); else if(!erlian(s)) printf("<%s> is not acceptable.\n",s); else printf("<%s> is acceptable.\n",s); } return 0;}
0 0
- HDU 1039.Easier Done Than Said?【字符串处理】【8月24】
- hdu 1039 (Easier Done Than Said?)(字符串处理)
- HDOJ/HDU 1039 Easier Done Than Said?(字符串处理~)
- HDU-1039-Easier Done Than Said?(简单字符串处理)
- hdu 1039 Easier Done Than Said? 字符串
- HDU--1039:Easier Done Than Said? (字符串)
- Easier Done Than Said?(字符串)
- hdu Easier Done Than Said?
- hdu 1039 Easier Done Than Said?(字符串模拟)
- HDU 1039-Easier Done Than Said?(字符串)
- HDU 1039 Easier Done Than Said? (字符串)
- HDOJ 1039 Easier Done Than Said? 简单的字符串处理
- HDOJ 1039 Easier Done Than Said? 简单的字符串处理
- poj 1575 Easier Done Than Said?【字符串处理】
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easyui Datebox设置可选时间范围
- System.Net.HttpWebRequest.GetRequestStream超时问题
- Android基础之Android的系统体系结构
- 使用Inotify实时同步文件夹
- 读取excel数据并保存为xml
- HDU 1039.Easier Done Than Said?【字符串处理】【8月24】
- 【笔试】20、单例模式
- mysql索引的类型和优缺点
- 幂取模
- VMWARE虚拟化环境下对GPU的配置说明
- Spark 学习资料整理
- 几个需要关注的问题
- 用NEXUS搭建MAVEN私服
- 创建数据库并带编码