String HDU 1039

Source: Internet
Author: User

Rules:

1. must contain at least one vowel letter. A E i o u

2. Cannot contain three consecutive vowels or consecutive consonant letters.

3. Cannot contain two consecutive letters, except ' ee ' and ' oo '.

PS: Number of letters (1<= N <=20).

#define_crt_secure_no_deprecate#include<stdio.h>#include<stdlib.h>#include<string.h>intIs_vowel (CharStrin) {    if(Strin = ='a'|| Strin = ='e'|| Strin = ='I'|| Strin = ='o'|| Strin = ='u')        return 1; Else        return 0;}voidMain () { while(1)    {        Charstrin[ +] = {' /'}; Charstrtemp[ +] = {' /'};//character cache, used to determine whether the same character appears consecutively        Chartemp; intCount =0;//statistics consecutive same number of letters        intCount2 =0;//count consecutive vowels or consonant letters        intVowelflag =0;//is the sign of the vowel bit        intLastisvowel =0;//whether the previous letter is a vowel sign bit 0 is not 1 is        intSign =0;//whether it contains a vowel marker bit        intResultfalg =1; intLen//Save the length of the input stringgets (Strin); Len= (int) strlen (Strin); //decide whether to end the query flag first        if(strcmp (Strin,"End") ==0)            return; Temp= strin[0]; Count=1; Count2=1; Vowelflag= Is_vowel (strin[0]); Lastisvowel= Is_vowel (strin[0]); //find if a vowel letter is included, if you encounter 3 consecutive vowels, consonant letters or 2 consecutive letters other than ' EE ' oo ', you are judged unacceptable and exit the loop         for(inti =0; i < Len; i++)        {            if(Sign = =0) Sign=Is_vowel (Strin[i]); //If the same letter appears            if(I >0&& temp = =Strin[i]) {Count++; if(Count = =2)                {                    if(Temp! ='e'&& Temp! ='o') {Resultfalg=0;//not receive, jump out of the loop                         Break; }                }            }            //if three consecutive vowels or three consecutive consonants appear            if(I >0) {Vowelflag=Is_vowel (Strin[i]); if(Vowelflag = =Lastisvowel) {Count2++; if(Count2 >=3) {Resultfalg=0;//not receive, jump out of the loop                         Break; }                }                Else{Count2=1; Lastisvowel=Vowelflag; }} Temp=Strin[i]; Count=1; }        if(Sign = =1&& Resultfalg! =0) {printf ("<%s> is acceptable.", Strin); printf ("\ n"); }        Else{printf ("<%s> is not acceptable.", Strin); printf ("\ n"); }    }}

String HDU 1039

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.