HDU 1049-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): 14333    Accepted Submission(s): 6944


题目链接:点击打开链接



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.
 

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
  
  
a tv ptoui bontres zoggax wiinq eep houctuh end
 

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.

 

题意:

问题描述

密码安全是一个棘手的问题。用户更喜欢简单的密码,因为很容易记住(如buddy),但这样的密码通常是不安全的。一些网站使用随机生成的密码(如xvtpzyo),但有时用户很难记住他们,然而他们坚持自己的电脑上设置密码。一个潜在的解决方案是生成可发音的“相对安全,但仍然容易记住的密码。FnordCom正在开发这样一个密码生成器。你在质量控制部门工作,这是你的工作来测试生成器和确保密码是可以接受的。是可以接受的,密码必须满足这三个规则:
它必须包含至少一个元音。
它不能包含三个连续的元音或连续三个辅音。
它不能包含两个连续出现相同的信,除了“ee”或“oo”。

(这个问题的目的,元音字母“a”,“e”,“我”,“o”,和“u”;所有其他辅音字母)。注意,这些规则是不完美的;有许多常见的/可发音的单词,是不能接受的。
 
输入
输入由一个或多个潜在的密码,每行一个,紧随其后的是一行只包含这个词“结束”信号文件的末尾。每个密码都至少有一个,最多二十信长,仅由小写字母。
 
输出
对于每一个密码,输出是否接受,使用精确的格式示例所示。

 

分析:

用几个变量标记控制一下就好。



#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
using namespace std;

int main()
{
    char yy[5]={'a','e','i','o','u'};
    char s[105];
    while(~scanf("%s",s))
    {
        if(s[0]=='e'&&s[1]=='n'&&s[2]=='d')
            break;
        int a=0,b=0,c=0,d=0;
        for(int i=0;i<strlen(s);i++)
        {
            if(s[i]==yy[0]||s[i]==yy[1]||s[i]==yy[2]||s[i]==yy[3]||s[i]==yy[4])
            {
                a++;
                b++;
                c=0;
            }
            if(b>2)
                break;
            if(!(s[i]==yy[0]||s[i]==yy[1]||s[i]==yy[2]||s[i]==yy[3]||s[i]==yy[4]))
            {
                b=0;
                c++;
            }
            if(c>2)
                break;
            if(s[i]==s[i+1]&&s[i]!='o'&&s[i]!='e')
            {
                d=1;
                break;
            }
        }
        if(d==1||a==0||b==3||c==3)
            printf("<%s> is not acceptable.\n",s);
        else
            printf("<%s> is acceptable.\n",s);
    }
    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值