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

hdu 1039 (string process, fgets, scanf, neat utilization of switch clause) 分类: hdoj 2015-06-16 22:15 38人阅读 评论(0) 收藏的更多相关文章

  1. Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏

    胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Subm ...

  2. Digital Roots 分类: HDU 2015-06-19 22:56 13人阅读 评论(0) 收藏

    Digital Roots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  3. Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏

    Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  4. u Calculate e 分类: HDU 2015-06-19 22:18 14人阅读 评论(0) 收藏

    u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  5. Hdu 1009 FatMouse' Trade 分类: Translation Mode 2014-08-04 14:07 74人阅读 评论(0) 收藏

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. hdu 1034 (preprocess optimization, property of division to avoid if, decreasing order process) 分类: hdoj 2015-06-16 13:32 39人阅读 评论(0) 收藏

    IMO, version 1 better than version 2, version 2 better than version 3. make some preprocess to make ...

  7. string 与char* char[]之间的转换 2015-04-09 11:30 29人阅读 评论(0) 收藏

    1.首先必须了解,string可以被看成是以字符为元素的一种容器.字符构成序列(字符串).有时候在字符序列中进行遍历,标准的string类提供了STL容器接口.具有一些成员函数比如begin().en ...

  8. HDU 1754 I Hate It 2016-09-14 19:01 27人阅读 评论(0) 收藏

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  9. hdu 1047 (big integer sum, fgets or scanf, make you func return useful infos) 分类: hdoj 2015-06-18 08:21 39人阅读 评论(0) 收藏

    errors made, boundary conditions, <= vs < , decreasing vs increasing , ++, –, '0'/'1' vs 0/1 p ...

随机推荐

  1. WORD基础快捷键

    选择 Alt+Shift+上下     移动整行 Ctrl+上             移动到行首 Ctrl+Shift+上下     选择到行首尾 shift+del         删除整段   ...

  2. Hadoop之为何不使用RAID?

    一.引言: 在一次和同事的讨论中遇到一个这样的问题:有一个hadoop集群,在hbase的put数据出现瓶颈,他们想要把datanode上的磁盘做成RAID 0(比如10块磁盘做成一个RAID 0), ...

  3. python:页面布局 后台管理页面之常用布局

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  4. wf(三)

    前言: 到现在我们可以看到,WF4包含一个.xmal 文件的设计器和一个调用活动的runtime.当你创建自己的工作流的时候,你是同时也创建了一个活动, 因为活动是一个继承System.Activit ...

  5. 回传数据startActivityForResult()

    1.调用者Activity01开启新的界面选用startActivityForResult(intent,requestCode);在Activity01中Intent intent=new Inte ...

  6. 凯撒加密(key为3)

    基本思想: 加密是把字符串中的每一个字符+3解密是每一个字符-3 源代码: package demo;import java.util.Scanner; class Encryption{ Strin ...

  7. JQ写简单的伸缩菜单(内附效果图和源代码)

    效果如图: JQ代码就那么几句, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...

  8. python_way ,day25 wmi

    pip install wmi  如果不能安装,就使用 安装 python3 -m pip install wmi 再安装pywin32这个包 使用: import platform import w ...

  9. JAVA 列表排序

    以前都通过Comparator进行排序,今天看到个例子,通过apache-common工具包进行排序,实现例子参考下面界面 http://blog.csdn.net/lizeyang/article/ ...

  10. 高斯混合模型与EM算法

    对于高斯混合模型是干什么的呢?它解决什么样的问题呢?它常用在非监督学习中,意思就是我们的训练样本集合只有数据,没有标签. 它用来解决这样的问题:我们有一堆的训练样本,这些样本可以一共分为K类,用z(i ...