hdu_1039_Easier Done Than Said_201311051511
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
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.
#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的更多相关文章
随机推荐
- activiti安装-------安装插件
对上面的放大
- java—容器学习笔记
一:迭代器 刚开始学容器,做了个简单的练习题.. import java.util.ArrayList; import java.util.Collection; import java.util.I ...
- php settype()和gettype()
gettype()是获得变量的类型,settype()函数用来配置或转换变量类型.成功返回 true 值,其它情形返回 false 值.参数 var 为原来的变量名,参数 type 为下列的类型之一: ...
- 安科 OJ 1054 排队买票 (递归,排列组合)
时间限制:1 s 空间限制:128 M 题目描述 有M个小孩到公园玩,门票是1元.其中N个小孩带的钱为1元,K个小孩带的钱为2元.售票员没有零钱,问这些小孩共有多少种排队方法,使得售票员总能找得开零钱 ...
- 拼接html 的事件转义
attach += "<div style='line-height: 10px;float: left;margin-left: 10px;' id='attach_" + ...
- js 调用微信浏览器内置方法,启动支付
$.post("{php echo app_url('pay/cash')}",{orderno:orderno,paytype:paytype},function(m){ //t ...
- Java中static方法
今天学习到了并且应用到了java中的静态方法,并且了解到它的好处与缺点. ● 生命周期(Lifecycle): 静态方法(Static Method)与静态成员变量一样,属于类本身,在类装载的时候被装 ...
- 【LeetCode】-- 73. Set Matrix Zeroes
问题描述:将二维数组中值为0的元素,所在行或者列全set为0:https://leetcode.com/problems/set-matrix-zeroes/ 问题分析:题中要求用 constant ...
- 浅谈Java中的hashcode方法以及equals方法
哈希表这个数据结构想必大多数人都不陌生,而且在很多地方都会利用到hash表来提高查找效率.在Java的Object类中有一个方法: public native int hashCode(); 根据这个 ...
- 1A课程笔记分享_StudyJams_2017
1A课程 概述 课程1A主要讲解了Android UI的三种基本控件:TextView.ImageView以及Button.笔记的主体内容主要根据课程内容的讲解顺序来组织,此外我对一些个人比较感兴趣的 ...