Death Knight Hero解题报告
2013-08-23 20:35
183 查看
题目摘要: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;
}
解题感想:简单水题
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;
}
解题感想:简单水题
相关文章推荐
- 2009年第一周学习报告
- 第五周实验报告2
- UVA 196 Spreadsheet 解题报告
- Uva 120 Stacks of Flapjacks 解题报告
- ANT:自动测试、生成测试报告
- 《信息安全系统设计基础》实验三实验报告
- 软件工程第三周例行报告
- POJ 2808 校门外的树 解题报告
- C++程序设计实验报告【5.1.3】
- 家庭理财系统实验报告
- LeetCode: Regular Expression Matching 解题报告
- 「会会」产品体验报告
- 测试进度报告(个人)
- 第四次作业--项目选题报告(团队)
- Google 发布最新 IDC 能源消耗报告
- 第五周实验报告(二)
- CXF启动报告LinkageError异常以及Java的endorsed机制
- LeetCode: Word Ladder II 解题报告
- [leetcode] 9. Palindrome Number 解题报告
- (第十一周)约跑APP测试报告