aoj 31 Counting Sheep
来源:互联网 发布:单片机培训网 编辑:程序博客网 时间:2024/06/14 09:15
题目链接:http://ccpc.ahu.edu.cn:8000/OJ/Problem.aspx?id=31
题目描述:
Description
After a long night of coding, Charles Pearson Peterson is having trouble sleeping. This is not only
because he is still thinking about the problem he is working on but also due to drinking too much java
during the wee hours. This happens frequently, so Charles has developed a routine to count sheep. Not
the animal, but the word. Specifically, he thinks of a list of words, many of which are close in spelling
to "sheep", and then counts how many actually are the word"sheep". Charles is always careful to
be case-sensitive in his matching, so "Sheep" is not a match. You are to write a program that helps
Charles count "sheep".
because he is still thinking about the problem he is working on but also due to drinking too much java
during the wee hours. This happens frequently, so Charles has developed a routine to count sheep. Not
the animal, but the word. Specifically, he thinks of a list of words, many of which are close in spelling
to "sheep", and then counts how many actually are the word"sheep". Charles is always careful to
be case-sensitive in his matching, so "Sheep" is not a match. You are to write a program that helps
Charles count "sheep".
Input
Input will consist of multiple problem instances. The first line will consist of a single positive integer
n <= 20, which is the number of problem instances. The input for each problem instance will be on two
lines. The first line will consist of a positive integer m <=10 and the second line will consist of m words,
separated by a single space and each containing no more than 10 characters.
n <= 20, which is the number of problem instances. The input for each problem instance will be on two
lines. The first line will consist of a positive integer m <=10 and the second line will consist of m words,
separated by a single space and each containing no more than 10 characters.
Output
For each problem instance, you are to produce one line of output in the format:
Case i: This list contains n sheep.
The value of i is the number of the problem instance (we assume we start numbering at 1) and n is the
number of times the word "sheep" appears in the list of words for that problem instance. Output lines
should be separated by a single blank line.
Case i: This list contains n sheep.
The value of i is the number of the problem instance (we assume we start numbering at 1) and n is the
number of times the word "sheep" appears in the list of words for that problem instance. Output lines
should be separated by a single blank line.
Sample Input
OriginalTransformed45shep sheeps sheep ship Sheep7sheep sheep SHEEP sheep shepe shemp seep10sheep sheep sheep sheep sheep sheep sheep sheep sheep sheep4shape buffalo ram goat
Sample Output
OriginalTransformedCase 1: This list contains 1 sheep.Case 2: This list contains 3 sheep.Case 3: This list contains 10 sheep.Case 4: This list contains 0 sheep.
AC代码:
#include<iostream>#include<cmath>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;char ch[105];int main(){ int n; cin>>n; for(int num=1;num<=n;num++) { int sum=0,m; cin>>m; while(m--) { scanf("%s",ch); if(strcmp(ch,"sheep")==0) sum++; } printf("Case %d: This list contains %d sheep.\n",num,sum); if(num!=n) cout<<endl; } return 0;}
水题。。。。。。
0 0
- aoj 31 Counting Sheep
- AOJ-AHU-OJ-31 Counting Sheep
- Counting Sheep
- Counting Sheep
- HDU2952 ( Counting Sheep )
- HDU 2952 Counting Sheep
- hdu 2952 Counting Sheep
- HDU2952:Counting Sheep(DFS)
- HDU2952:Counting Sheep(BFS)
- HDU2952 Counting Sheep
- hdu_2952 Counting Sheep
- hdu2952(DFS Counting Sheep )
- hdu-2952-Counting Sheep
- hdu 2952 Counting Sheep
- hdu 2952Counting Sheep
- HDU2952:Counting Sheep(DFS)
- HDU2952:Counting Sheep(BFS)
- HDU 2952 Counting Sheep
- LeetCode226. Invert Binary Tree
- C/C++中调用外部文件的函数时如何编写头文件
- Android应用开发性能优化完全分析
- VS 2010 的 Cannot find or open the PDB file发生的可能原因
- [uC/OS-II原理及应用]uC/OS-II的中断和时钟
- aoj 31 Counting Sheep
- 添加html元素的事件
- <机器学习笔记-02> <scikit-learn -02>线性回归
- Linux基础学习--忘记root密码找回方法
- 2016-09-27 上海/
- PHP 10进制与62进制互转,可用于生成短网址
- 一些面试题2016-9-6分享
- JAVA基础6.34——Static关键字(1)
- VS2012 打开项目提示asp.net 4.0尚未在web服务器上注册