Easier done Than said? Time Limit:2 Seconds Memory limit:65536 KB
Password security is a tricky thing. Users prefer simple passwords that is easy to remember (like Buddy), but such passwords is often insecure. Some sites use random computer-generated passwords (like Xvtpzyo), but users has a hard time remembering them and Sometim Es leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that's 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 is a Cceptable. To is 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 the consecutive occurrences of the same letter, and except for ' ee ' or ' oo '.
(For the purposes of this problem, the vowels is ' a ', ' e ', ' I ', ' o ', and ' u '; all other letters is consonants.) Note that these rules is not perfect; There is many common/pronounceable words that is not acceptable.
Input
The input consists of one or more potential passwords, one per line, followed by a line containing only the word ' end ' tha T signals the end of the file. Each password are at least one and at the most twenty letters long and consists only of lowercase letters.
Output
For each password, the output whether or isn't 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.
Source:mid-central USA 2000
Analysis:
Test instructions
Give a password (all lowercase letters, up to 20 characters in length) and ask to determine if the password is acceptable. A password is acceptable and must meet the following three conditions:
(1) The string contains at least one vowel letter (a,e,i,o,u).
(2) The string does not contain three consecutive vowels or three consecutive consonants.
(3) cannot contain two identical consecutive letters, except EE and oo.
Simple question. It is a direct judgment of whether the three conditions are met at the same time. Because only 20 characters, using char[] processing is enough.
Note: the C language line does not write how to change the line reference Answer
With the connector \
Like what
Char A[]={a,b,a,b,a,b,a,b,a,b,a,b,a,b, \
C
AC Code:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace Std;
Char c[22];
int main ()
{
int i,j;
while (scanf ("%s", c) &&strcmp (c, "end")!=0)
{
BOOL flag=0;
int L=strlen (c);
for (i=0;i<l;i++)
{
if (c[i]== ' A ' | | c[i]== ' E ' | | c[i]== ' I ' | | c[i]== ' O ' | | c[i]== ' u ')
flag=1;
if (i>1)
{
if ((c[i]== ' A ' | | c[i]== ' E ' | | c[i]== ' I ' | | c[i]== ' O ' | | c[i]== ' u ') \
&& (c[i-1]== ' A ' | | c[i-1]== ' E ' | | c[i-1]== ' I ' | | c[i-1]== ' O ' | | c[i-1]== ' u ') \
&& (c[i-2]== ' A ' | | c[i-2]== ' E ' | | c[i-2]== ' I ' | | c[i-2]== ' O ' | | c[i-2]== ' u ')) \
|| ((c[i]!= ' a ' &&c[i]!= ' e ' &&c[i]!= ' i ' &&c[i]!= ' o ' &&c[i]!= ' u ') \
&& (c[i-1]!= ' a ' &&c[i-1]!= ' e ' &&c[i-1]!= ' i ' &&c[i-1]!= ' o ' &&c[i-1]!= ' u ') \
&& (c[i-2]!= ' a ' &&c[i-2]!= ' e ' &&c[i-2]!= ' i ' &&c[i-2]!= ' o ' &&c[i-2]!= ' U ')))
Break
}
if (i>0)
{
if (c[i]==c[i-1]&& (c[i]!= ' e ' &&c[i]!= ' o '))
{
printf ("%d", I);
Break
}
}
}
printf ("<%s> is", c);
if (flag&&i==l)
printf ("acceptable.\n");
Else
printf ("Not acceptable.\n");
}
return 0;
}