zoukankan      html  css  js  c++  java
  • 充满恶意的单词

    Description

    Ryan经常吐槽Rnc的发音,但是有一天Rnc的嘲讽模式全开,打算让Ryan涨涨姿势。 Rnc为Ryan准备了许多许多的单词,这些单词可以很长很长(hippopotomonstrosesquippedaliophobia [长单词恐惧症]),还可以大小写混杂(MaLIcE)。 Ryan认为有些单词是正常的,而另外一些单词则充满了Rnc的恶意。 Ryan认为如果一个单词包含了连续的两个或以上的元音(a,e,i,o,u)且这些元音不全相同,那么这个单词就充满了恶意。(比如goal和beauty等等) Ryan还认为如果一个单词包含了连续三个或以上的辅音(除了元音) ,这个单词也充满了恶意。(比如street和first等等) 看到这里聪明的你一定知道Ryan来找你帮什么忙了,是的,就是判断Rnc给的单词是否充满了恶意,是则输出YES,否则输出NO。 PS:在本题中,y在任何情况下都认为是辅音。

    Input

    第一行是数据组数T (T≤500)。 对于每组数据,有一行,只包含大小写混合的单词,长度不超过50。

    Output

    对于第k组数据,输出一行"Case #k: "然后输出你认为这个单词是否是充满了Rnc的恶意,是则输出YES,否则输出NO.

    Sample Input

    2 Need TRicKY

    Sample Output

    Case #1: NO Case #2: YES

    Source

    第八届北京交通大学ACM程序设计竞赛

     1 #include <iostream>
     2 #include <string.h>
     3 using namespace std;
     4 char temp[]="aeiouAEIOU";
     5 bool PanDuanIsYuanyin(char s)
     6 {
     7     bool isYuanYIN =false ;
     8     for(int j=0;j<strlen(temp);j++)
     9     {
    10         if(s==temp[j])
    11         {
    12             isYuanYIN= true;
    13             break;
    14         }
    15     }
    16     return isYuanYIN;
    17 }
    18 int main()
    19 {
    20     int count;
    21     cin>>count;
    22     int sum=count;
    23     while(count--)
    24     {
    25         char str[200];
    26         cin>>str;
    27         int num=1;
    28         char LastNum=str[0];
    29         bool biaoji=false;
    30         for(int i=1;i<strlen(str);i++)
    31         {
    32             if(PanDuanIsYuanyin(str[i]))
    33             {
    34                 if(PanDuanIsYuanyin(LastNum))
    35                 {
    36                     if(toupper(str[i])!=toupper(LastNum))    
    37                     {
    38                         num++;
    39                     }
    40                     else
    41                     {
    42                         num=1;
    43                     }
    44                     if(num>=2)
    45                     {
    46                         biaoji=true;
    47                         break;
    48                     }
    49                 }
    50                 else{
    51                     num=1;
    52                 }
    53             }
    54             else 
    55             {
    56                 if(PanDuanIsYuanyin(LastNum))
    57                 {
    58                     num=1;
    59                 }
    60                 else{
    61                     num++;
    62                     if(num>=3)
    63                     {
    64                         biaoji=true;
    65                         break;
    66                     }
    67                 }
    68             }
    69             LastNum=str[i];
    70         }
    71         if(biaoji){
    72             cout<<"Case #"<<sum-count<<": YES"<<endl;
    73         }
    74         else{
    75             cout<<"Case #"<<sum-count<<": NO"<<endl;
    76         }
    77     }
    78     return 0;
    79 }
  • 相关阅读:
    软件测试(理论基础)
    Android NDK常见配置问题的解决方案
    Eclemma各种安装方式以及安装失败解决
    检测Buffer Overflow的几种方法
    转: 跟我一起写 Makefile
    流敏感、路径敏感、上下文敏感
    Symbolic Exectuion with Mixed ConcreteSymbolic Solving
    基于ajc的代码编织
    第一次个人编程作业
    第一次博客作业
  • 原文地址:https://www.cnblogs.com/jack-Star/p/4048112.html
Copyright © 2011-2022 走看看