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

InputThe 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.

OutputFor 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>

#define N 25

int fun(char p){

if(p==‘a‘||p==‘e‘||p==‘i‘||p==‘o‘||p==‘u‘)

return 1;

return 0;

}

int gun(int a[],int len){

int i,t;

int flag=0;

for(i=0;i<len-2;i++){

t=a[i]+a[i+1]+a[i+2];

if((t==0)||(t==3)){

flag=1;

break;

}

}

return flag;

}

int hun(char s[]){

int i,len;

int flag=0;

len=strlen(s);

for(i=0;i<len-1;i++){

if((s[i]==s[i+1])&&((s[i]!=‘e‘)&&(s[i]!=‘o‘))){

flag=1;

break;

}

}

return flag;

}

int main(){

char str[N]={0};

scanf("%s",str);

while(strcmp(str,"end")){

int count=0;

int a[20]={0};

int len=0;

len=strlen(str);

//while(scanf("%s",str),str!="end"){

for(int i=0;i<len;i++){

if(fun(str[i])){

a[i]=1;

if(!count)  count=1;

}

else       a[i]=0;

}

if(!count)        printf("<%s> is not acceptable.\n",str);

else if(gun(a,len))

printf("<%s> is not acceptable.\n",str);

else if(hun(str))

printf("<%s> is not acceptable.\n",str);

else               printf("<%s> is acceptable.\n",str);

scanf("%s",str);

}

return 0;

}

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

时间: 2024-10-12 08:07:55

Easier Done Than Said? 【杭电-1039】 附题的相关文章

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

杭电acm 1034题

Problem Description A number of students sit in a circle facing their teacher in the center. Each student initially has an even number of pieces of candy. When the teacher blows a whistle, each student simultaneously gives half of his or her candy to

杭电acm 1049题

一道水题..... 大意是一条1inch的虫子在一个n inch的盒子的底部,有足够的能够每一分钟往上爬u inch,但是需要休息一分钟,这期间会往下掉d inch,虫子爬到盒子口即认为结束.要求计算出给定的n,u,d虫子爬上的时间. 1 /****************************************************** 2 杭电acm 1049题 已AC 3 *****************************************************/

杭电acm 1076题

水题,一个求闰年的题目,复习一下闰年的求法.... 1,如果能被4整除但不能被100整除的是闰年 2,能被400整除的是闰年 题目大意是:给定一个开始年份T以及一个正数N,要求求出从T开始,到了哪一年刚好是第N个闰年,如果开始年份是闰年则记为第一个闰年.... 1 /*********************************** 2 杭电acm 1076题 已AC 3 *************************************/ 4 #include <iostream>

hdu1867(A + B for you again) 杭电java a题真坑

点击打开链接 Problem Description Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as "asdf" and "sdfg", the result of the addition between them is

杭电acm 2018题

有一头母牛,它每年年初生一头小母牛.每头小母牛从第四个年头开始,每年年初也生一头小母牛.请编程实现在第n年的时候,共有多少头母牛? 因为前三年的小母牛到了第四年会生小牛,再加上前一年的母牛头数就是某年母牛的总数. f(1)=1; f(2)=2; f(3)=3; ......... f(n)=f(n-1)+f(n-3); #include<stdio.h> int f(int n); int main(void) { int n; while(scanf("%d",&

杭电acm 2013题

蟠桃记 喜欢西游记的同学肯定都知道悟空偷吃蟠桃的故事,你们一定都觉得这猴子太闹腾了,其实你们是有所不知:悟空是在研究一个数学问题! 什么问题?他研究的问题是蟠桃一共有多少个! 不过,到最后,他还是没能解决这个难题,呵呵^-^ 当时的情况是这样的: 第一天悟空吃掉桃子总数一半多一个,第二天又将剩下的桃子吃掉一半多一个,以后每天吃掉前一天剩下的一半多一个,到第n天准备吃的时候只剩下一个桃子.聪明的你,请帮悟空算一下,他第一天开始吃的时候桃子一共有多少个呢? 这道题目几个月以前用循环做过,最近想重温下

杭电 1262 寻找素数对 【素数】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1262 解题思路:先将题目中给出的偶数范围内的素数打表,设输入的那个偶数为n,这样找到n/2在素数表的位置k,从pn[k]到pn[2]:以及从pn[k]到pn[10000]依次判断相加是否等于n即可. 反思:注意像 10和26这样的偶数,应该输出的是 5 5:13 13:所以应该单独处理这种n/2等于一个素数的偶数 ps:这是在杭电的100题,这三个多月来,加油!!!!!fighting!!!!!!

进制转换,杭电0j-2031

进制转换,杭电0j-2031原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=2031 [Problem Description] 输入一个十进制数N,将它转换成R进制数输出. [Input] 输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(2<=R<=16, R<>10). [Output] 为每个测试实例输出转换后的数,每个输出占一行.如果R大于10,则对应的数字规则参考16进制(比如,10用A表示,等等).