zoukankan      html  css  js  c++  java
  • hdu 1039 (string process, fgets, scanf, neat utilization of switch clause) 分类: hdoj 2015-06-16 22:15 38人阅读 评论(0) 收藏

    (string process, fgets, scanf, neat utilization of switch clause)
    simple problem, simple code.

    #include <cstdio>
    #include <algorithm>
    
    #define MAXLEN 22
    char password[MAXLEN];
    
    int main() {
        //freopen("input.txt","r",stdin);
        int nc,nv,vcnt, invalid;
        char *p;
        while(scanf("%20s",password)==1 && strcmp(password,"end")!=0) {
            nc=nv=vcnt=0; invalid=0;
            p=password-1;
            while(*++p) {
                switch(*p) {
                case 'e':
                case 'o':
                case 'a':
                case 'i':
                case 'u':
                    ++vcnt; ++nv; nc=0; break;
                default:
                    ++nc; nv=0; break;
                }
                if(*p==*(p+1) && *p!='e' && *p!='o') { invalid=1; break; }
                if(nc>2 || nv>2) { invalid=1; break; }
            }
            if(invalid || vcnt==0) printf("<%s> is not acceptable.
    ",password);
            else printf("<%s> is acceptable.
    ",password);
        }
        return 0;
    }
    

    版权声明:本文为博主原创文章,未经博主允许不得转载。// p.s. If in any way improment can be achieved, better performance or whatever, it will be well-appreciated to let me know, thanks in advance.

  • 相关阅读:
    支付宝API
    三级联动
    高精尖面试题(七)
    高精尖面试题(六)
    高精尖面试题(五)
    第十二章、使用继承
    第十章、使用数组
    第十一章、理解参数数组
    第九章、使用枚举和结构创建值类型
    第八章、理解值类型和引用
  • 原文地址:https://www.cnblogs.com/qeatzy/p/4716228.html
Copyright © 2011-2022 走看看