Easier Done Than Said?
来源:互联网 发布:淘宝上原宿是什么意思 编辑:程序博客网 时间:2024/05/12 22:32
Easier Done Than Said?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8369 Accepted Submission(s): 4102
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.
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
atvptouibontreszoggaxwiinqeephouctuhend
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.
<span style="font-size:14px;">/*题解: 先将题中给的每一个条件都写成函数,再调用函数,在以后的练习中还 多多注意函数的使用和练习。 */#include<stdio.h>#include<stdlib.h>#include<string.h>int is_vowel(char c)//判断是否是元音字母 {if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')return 1;return 0;}int pw1(char st[20])//至少有一个元音 {int len,i;len=strlen(st);for(i=0;i<len;i++){if(is_vowel(st[i]))//调用函数is_vowel return 1;}return 0;}int pw2(char st[20])//判断是否是三个连续的元音或者辅音 {int len,i;len=strlen(st);for(i=0;i<len-2;i++){if(is_vowel(st[i])&&is_vowel(st[i+1])&&is_vowel(st[i+2]))//再次调用is_vowel return 0;if(!is_vowel(st[i])&&!is_vowel(st[i+1])&&!is_vowel(st[i+2])) return 0;}return 1;}int pw3(char st[20])//判断两个连续的字符是否是ee或oo {int i,len;len=strlen(st);for(i=0;i<len-1;i++){if(st[i]==st[i+1]&&st[i]!='e'&&st[i]!='o') return 0;}return 1;}int main(){char st[20];while(gets(st)&&strcmp(st,"end")!=0){if(pw1(st)&&pw2(st)&&pw3(st))//满足这三个条件的acceptable {printf("<%s> is acceptable.\n",st);//注意accptable后面还有一个点,否则会WA } else printf("<%s> is not acceptable.\n",st);}//system("pause");return 0;}</span>
0 0
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- Easier Done Than Said?
- hdu Easier Done Than Said?
- 1039 Easier Done Than Said?
- 题目:Easier Done Than Said?
- HDU1039:Easier Done Than Said?
- TJU Easier Done than Said?
- HDU1039:Easier Done Than Said?
- 1911. Easier Done than Said?
- [C How To Program] 习题5.37 x的n次方
- Linux之ubuntu学习笔记(一):熟悉命令语法和多用户概念
- PowerDesigner反向工程 mysql
- linux下开机挂在win7分区
- 运行在Linux上的10大半自动机器人
- Easier Done Than Said?
- Min Number
- C#操作Excel
- Javase基础学习笔记之String StringBuffer
- 23种设计模式-4-建造者模式
- 查找c语言程序中基本的语法错误
- 书都不会读,你还想成功—读书笔记
- linux0.11内核空间与用户空间数据交换
- Android proguard 详解