Hust oj 1497 Death Knight Hero(字符串水题)

来源:互联网 发布:故宫淘宝是故宫开的吗 编辑:程序博客网 时间:2024/06/06 02:30
Death Knight HeroTime Limit: 1000 MSMemory Limit: 65535 KTotal Submit: 31(18 users)Total Accepted: 20(17 users)Rating: Special Judge: NoDescription

     There once was a champion of WoW  Arthasdkthe name he was bestowed He Death Gripped you to his side His Chains of Ice stopped your stride And Obliterates made you say "OWW!"

     But one day our hero got puzzled ,His Death Grip totally fizzled In his darkest despair He could barely hear "OMG NOOB u Chains of Iced than u Death Gripped".

Input

You are given a recording of the abilities our hero used in his battles.

There are several test cases. For each test case:

The first line of input will contain a single integer n(1<=n<=100), the number of battles our hero played.

Then follow n lines each with a sequence of ki ((1<=ki <=1000) characters, each of which are either 'C', 'D'   or 'O'.  These denote the sequence of abilities used by our hero in the i-th battle. 'C' is Chains of Ice, 'D' is Death Gripand 'O' is Obliterate.

Output For each test case,Output the number of battles our hero won, assuming he won each battle where he did
not Chains of Ice immediately followed by Death Grip.Sample Input3
DCOOO
DODOCD
CODSample Output

2

最烦翻译题。。。输入n个字符串,问有几个字符串中不包含连着的CD

#include<cstdio>#include<cstring>#include<iostream>using namespace std;int n;const int Maxn = 1005;char str[Maxn];int main(){    while(~scanf("%d",&n))    {        int temp = n;        for(int i=0;i<n;i++)        {            scanf("%s",&str);            int flag = 0;            int len = strlen(str);            for(int i=1;i<len;i++)            {                if(str[i] == 'D' && str[i-1] == 'C')                {                    flag = 1;                }            }            if(flag)                temp--;        }        printf("%d\n",temp);    }}


 

0 0