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.

  • 相关阅读:
    控件显示和隐藏
    删除标题和边框
    界面图片
    VC界面最前端显示
    在VC++6.0开发中实现全屏显示
    VC比例放大缩小
    plsql dev
    通过OCCI连接oracle(C++)
    VC++使用Pro*CC++
    文件对话框
  • 原文地址:https://www.cnblogs.com/qeatzy/p/4716228.html
Copyright © 2011-2022 走看看