Death Knight Hero解题报告

本文介绍了一道关于《魔兽世界》中死亡骑士战斗策略的编程题,玩家需避免在战斗中先使用冰链再接死亡之握的错误操作顺序,通过分析不同战斗中的技能使用顺序来判断胜败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目摘要:There once was a champion of WoW

Arthasdk the 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 DeathGripped"

输入输出要求

Input:

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

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

Then follow n lines each with a sequence ofki (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-thbattle. 'C' is Chains of Ice, 'D' is Death Grip and 'O' is Obliterate.

Output:

Output the number of battles ourhero won, assuming he won each battle where he did not Chains of Iceimmediately followed by Death Grip.

题目大意:Death Knight Hero有三个技能,他要进行n场战斗,如果他放完技能C然后立刻放技能D,那么他就会输。要求计算他能赢的场数。

输入输出样例

Sample Input

3

DCOOO

DODOCD

COD

Sample Output

2

 

解题思路:对每个字符串都扫一遍,如果有CD那么赢的场数减一。

代码

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
char str[1005];
int Judge()
{
    int i;
    for(i=0;i<strlen(str)-1;i++)
    {
        if((str[i]=='C')&&(str[i+1]=='D'))
            return 1;
    }
    return 0;
}
int main()
{
    int N;
    while(cin>>N)
    {
        int sum=N;
        while(N--)
        {
            cin>>str;
            if(Judge())
                sum--;
        }
        cout<<sum<<endl;
    }
    return 0;
}

解题感想:简单水题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值