D1164:Easier Done Than Said?

描述
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.

输入
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.
输出
For each password, output whether or not it is acceptable, using the precise format shown in the example.
样例输入
a tv ptoui bontres zoggax wiinq eep houctuh end
样例输出

is acceptable.
is not acceptable.
is not acceptable.
is not acceptable.
is not acceptable.
is not acceptable.
is acceptable.
is acceptable.

思路:输入数据,每输入一个数据判断是否接受,如果有元音j++;a判断连续的元音个数,b判断连续的辅音个数,c判断除了“ee”或“oo”外是否有连续相同的两个字母,最后判断该单词是否可被接受。

代码:

#include#includeusing namespace std;int main(){        char a[5]="end";        char data[20];        while(cin>>data)        {                if(strcmp(data,a)==0)                        return 0;                int i,j=0,a=0,b=0,c=0;                int n=strlen(data);                for(i=0;i                {                       if(data[i]==‘a‘||data[i]==‘e‘||data[i]==‘i‘||data[i]==‘o‘||data[i]==‘u‘)                        {                                j++;                                a++;                                b=0;                                if(data[i]==data[i+1]&&data[i]!=‘e‘&&data[i]!=‘o‘)                                        c++;                        }                        else                        {                                b++;                                if(data[i]==data[i+1]&&data[i]!=‘e‘&&data[i]!=‘o‘)                                        c++;                                a=0;                        }                        if(a==3||b==3)                                break;                }                if(j!=0&&c==0&&a<3&&b<3)                        cout<<"<"<<data<<">"<<" is acceptable."<<endl;                else                        cout<<"<"<<data<<">"<<" is not acceptable."<<endl;                }                return 0;}
时间: 2024-10-29 10:48:16

D1164:Easier Done Than Said?的相关文章

Easier Done Than Said?(杭电oj1039)

Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8339    Accepted Submission(s): 4093 Problem Description Password security is a tricky thing. Users prefer simple password

HDU1039 Easier Done Than Said?

Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7822    Accepted Submission(s): 3863 Problem Description Password security is a tricky thing. Users prefer simple password

ural 1356. Something Easier 哥德巴赫猜想

1356. Something Easier Time limit: 1.0 secondMemory limit: 64 MB “How do physicists define prime numbers? Very easily: prime numbers are the number 2 and all the odd numbers greater than 2. They may show that this definition corresponds to the mathem

Little things that can make your life easier in 2016

作为今年的结束,向你推荐一些工具,可以添加到你的iOS开发工具箱,并可以让你2016年的开发变得更容易.更高效. 使用用户断点的力量 我们使用断点的地方有很多,但我发现大多数朋友只使用常规断点进行调试. 实际上,还有很多你能用的地方,例如你可以把普通断点提升为用户断点,并且在你所有的项目中使用,为什么不这么做呢? 因为你可以在执行代码中创建一个特定的符号断点,例如UIApplicationMain: 看到我做了些什么吗? 现在每当调试任何的项目,我已经不这么做了: 我直接这么处理: 没有额外的步

Easier Done Than Said? 【杭电-1039】

/* Easier Done Than Said? Problem DescriptionPassword 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 xv

Easier Done Than Said? 【杭电-1039】 附题

/* Easier Done Than Said? Problem DescriptionPassword 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 xv

1658: Easier Done Than Said?

1658: Easier Done Than Said? Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 15  Solved: 12[Submit][Status][Web Board] Description Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passw

hdu 1039 - Easier Done Than Said?

题目:给你一个小写字符串,判断是否安全,安全规则如下: 1.包含元音字母:2.相邻3个元素不能都是元音或辅音:3.连续2个字母相同之能是o或e. 分析:简单题.直接模拟即可. 说明:今天有点累╮(╯▽╰)╭,要学的东西好多( ⊙ o ⊙ )啊! #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #incl

HDU 1039[Easier Done Than Said?] 字符串处理

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1039 题目大意:给一个字符串,看是否符合密码的要求. 规则:1.至少有1个元音字母.2.不能有3个连续的元音字母或辅音字母3.不能有相同的字母连续出现(除了ee,oo) 关键思想:耐心地处理字符串 代码如下: //可优化 #include <iostream> #include <algorithm> #include <string.h> using namespace