(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.\n",password);
else printf("<%s> is acceptable.\n",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.

最新文章

  1. ubuntu15:10 163源
  2. jQuery实现AJAX定时刷新局部页面实例
  3. 版本管理之Git(二):Win7上Git安装及简单配置过程
  4. js比typeof更准确的验证类型方法
  5. Session案例:简易的购物车
  6. Delete website with command.
  7. BZOJ 1036: [ZJOI2008]树的统计Count( 树链剖分 )
  8. SVN学习之windows下svn的安装
  9. 【腾讯海纳】系统未发布时如何获取获取property_id在本地进行测试?
  10. 洛谷P1996 约瑟夫问题【链表】
  11. [C#]将数据写入已存在的excel文件
  12. 20. Web proxies (网页代理 4个)
  13. MVC HtmlHelper用法
  14. javascript 模拟日历
  15. cocos2d-x JS 字符串
  16. Linux 运维测试及第三应用及测试工具
  17. 每日英语:Boost Your Balance; Avoid Falls
  18. 用ARM实现音乐电子相册
  19. IT管理就这么管
  20. shell 字符串运算符

热门文章

  1. Hadoop编程1:天气数据AWK &amp; MapReduce
  2. url结构说明
  3. phpcms无法读取index.html的解决步骤
  4. win7 APPCRASH问题解决!
  5. GRUB学习笔记(转自http://www.cnblogs.com/evilzy/archive/2008/03/30/1130173.html)
  6. [转]关于NSAutoreleasePool&#39; is unavailable: not available in automatic reference counting mode的解决方法
  7. android 内存处理工具
  8. if,else语句的运用
  9. 【Nginx】配置Nginx的负载均衡
  10. ibatis mybatis sql语句配置 符号不兼容 大于号 小于号&lt;!CDATA[ ]&gt;