Easier Done Than Said?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6333    Accepted Submission(s): 3145

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.
 
 #include <stdio.h>
#include <string.h> char str[]; int f(char c)
{
if(c=='a')
return ;
else if(c=='e')
return ;
else if(c=='i')
return ;
else if(c=='o')
return ;
else if(c=='u')
return ;
else
return ;
} int consecutive(char a,char b,char c)
{
int t;
t=f(a)+f(b)+f(c);
if(t==||t==)
return ;
else
return ;
}
int main()
{
memset(str,,sizeof(str));
while(scanf("%s",str),strcmp(str,"end")!=)
{
int i,j,k=,t1=,t2=;
int len;
printf("<%s> ",str);
len = strlen(str);
for(i=;i<len;i++)
{
if(str[i]=='a')
k++;
else if(str[i]=='e')
k++;
else if(str[i]=='i')
k++;
else if(str[i]=='o')
k++;
else if(str[i]=='u')
k++;
if(i+<len)
{
if(consecutive(str[i],str[i+],str[i+]))
{
printf("is not acceptable.\n");
break;
}
}
if(str[i+]==str[i])
{
if(str[i]=='e'||str[i]=='o')
i++;
else
{
printf("is not acceptable.\n");
break;
}
}
}
if(k==&&i>=len)
printf("is not acceptable.\n");
if(k>&&i>=len)
printf("is acceptable.\n");
}
return ;
}
没有想象中的那么难,其实是一道简单题

hdu_1039_Easier Done Than Said_201311051511的更多相关文章

随机推荐

  1. Android Studio笔记

    1. toolbar xml: <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:la ...

  2. 学学cookie和session

    什么是Cookie? HTTP Cookie(也叫 Web Cookie或浏览器 Cookie)是服务器发送到用户浏览器并保存在本地的一小块数据,它会在浏览器下次向同一服务器发起请求时被携带并发送到服 ...

  3. array_column()函数兼容低版本

    array_column 用于获取二维数组中的元素(PHP 5.5新增函数),但我们有时候需要在低版本的 function i_array_column($input, $columnKey, $in ...

  4. Django基于JWT实现微信小程序的登录和鉴权

    什么是JWT? JWT,全称Json Web Token,用于作为JSON对象在各方之间安全地传输信息.该信息可以被验证和信任,因为它是数字签名的. 与Session的区别 一.Session是在服务 ...

  5. Spring Cloud (7) 服务容错保护-Hystrix服务降级

    在微服务架构中,根据业务来拆分成一个个的服务,服务与服务之间可以互相调用,在Spring Cloud可以用RestTemplate+Ribbon和Feign来调用.为了保证其高可用,单个服务通常会集群 ...

  6. Jquery 可拖拽的Ztree

    比较懒,就只贴关键代码吧,自己把有用的属性全部打印出来了,也加了不少注释. 保存后涉及到的排序问题,刷新问题还未考虑到,后面有的话再加. $.fn.zTree.init($("#ztree& ...

  7. 研磨JavaScript系列(三):函数的魔力

    JavaScript的代码中就只有function一种形式,function就是函数的类型.在其他的编程语言中可能还存在Procedure或者是method等代码概念,在JavaScript中只有fu ...

  8. Active Learning主动学习

    Active Learning主动学习 我们使用一些传统的监督学习方法做分类的时候,往往是训练样本规模越大,分类的效果就越好.但是在现实生活的很多场景中,标记样本的获取是比较困难的,这需要领域内的专家 ...

  9. JS高级——扩展内置对象的方法

    基本概念 内置对象有很多,几个比较重要的:Math.String.Date.Array 基本使用 1.内置对象创建出来的对象使用的方法使用的其实都是内置对象的原型对象中的方法 (1)a并没有charA ...

  10. 11、scala函数式编程

    1.将函数赋值给变量 2.匿名函数 3.高阶函数 4.高阶函数的类型推断 5.Scala的常用高级函数 6.闭包 7.SAM转换 8.Currying函数 9.return 1.将函数赋值给变量 Sc ...