zoukankan      html  css  js  c++  java
  • HDU 1039.Easier Done Than Said?-条件判断字符串

    Easier Done Than Said?

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


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

    代码:

     1 #include<stdio.h>
     2 #include<string.h>
     3 int main(){
     4     char a[100];
     5     int i,num,flag,len;
     6     int b[100];
     7     while(~scanf("%s",&a)&&strcmp("end",a)){
     8         for(i=0;i<100;i++)
     9             b[i]=0;
    10             num=0;
    11             flag=1;
    12             len=strlen(a);
    13         for(i=0;i<len;i++){
    14            if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'){
    15                 b[i]=1;
    16                 num+=1;
    17            }
    18            else
    19                 b[i]=2;
    20         }
    21         for(i=2;i<len;i++){
    22                 if(b[i]==b[i-1]&&b[i-1]==b[i-2]){
    23                     flag=0;
    24                     break;
    25                 }
    26         }
    27         for(i=1;i<len;i++){
    28                 if(a[i]==a[i-1]&&a[i]!='e'&&a[i]!='o'){
    29                     flag=0;
    30                     break;
    31                 }
    32         }
    33         if(num==0||flag==0)
    34             printf("<%s> is not acceptable.
    ",a);
    35         else
    36             printf("<%s> is acceptable.
    ",a);
    37     }
    38     return 0;
    39 }
  • 相关阅读:
    [转] RISC-V架构介绍
    SiP封装成超越摩尔定律的要塞,日月光/安靠/长电科技谁将赢取IC封装的未来
    OLED中的Demura
    第四次工业革命:人工智能(AI)入门
    星座图的原理与应用
    示波器基本原理之七:示波器的基本测量
    示波器基本原理之六:示波器的基本控制
    示波器基本原理之五:采集模式
    示波器基本原理之四:波形捕获率
    png的故事:隔行扫描算法
  • 原文地址:https://www.cnblogs.com/ZERO-/p/9740505.html
Copyright © 2011-2022 走看看