鏈接:
C. Death Knight Hero
Input
Output
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 Input
3 DCOOO DODOCD COD
Sample Output
2
code:
/**
題意:給你一個數 N
下面給出 N 個字符串代表 Hero 每次戰爭使用的技能
如果這次贏,則這串字符中不會出現 “CD”連在一起的情況
問:N次戰鬥,能贏幾場。。。
*/
#include<stdio.h>
#include<string.h>
const int maxn = 1000+10;
int n;
char str[maxn];
int main()
{
while(scanf("%d", &n) != EOF)
{
int ans = 0;
while(n--)
{
scanf("%s", str);
int len = strlen(str);
int flag = 1;
for(int i = 0; i < len-1; i++)
{
if(str[i] == 'C' && str[i+1] == 'D')
{
flag = 0; break;
}
}
if(flag) ans++;
}
printf("%d\n", ans);
}
return 0;
}