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".

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.

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. Two successive lines should be separated by a single blank line, but do not output any trailing blank line.

Sample Input

4
5
shep sheeps sheep ship Sheep
7
sheep sheep SHEEP sheep shepe shemp seep
10
sheep sheep sheep sheep sheep sheep sheep sheep sheep sheep
4
shape buffalo ram goat

Sample Output

Case 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.

Source: East
Central North America 2000 Practice

 #include <stdio.h>
#include <string.h> char str[];
char sheep[] = "sheep"; int main ()
{
int m,n;
int numCount;
scanf("%d",&m);
int i=;
while(i<m)
{
numCount=;
scanf("%d",&n);
getchar();
gets(str);
char *ptr = str;
while(n--)
{
int j;
if((memcmp(ptr,sheep,) == )&&((*(ptr+) == ' ')||(*(ptr+) == '\0')))
{
numCount++;
ptr+=;
}
else
{
for(j=;j<;j++)
{
if(*ptr++ != ' ')
continue;
break;
}
}
}
printf("Case %d: This list contains %d sheep.\n",++i,numCount);
if(i<m)
printf("\n");
numCount = ;
}
return ;
}

2001. Counting Sheep的更多相关文章

  1. 【DFS深搜初步】HDOJ-2952 Counting Sheep、NYOJ-27 水池数目

    [题目链接:HDOJ-2952] Counting Sheep Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 ...

  2. Counting sheep...

    Counting sheep... Description: Consider an array of sheep where some sheep may be missing from their ...

  3. HDU-2952 Counting Sheep (DFS)

    Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  4. HDU 2952 Counting Sheep(DFS)

    题目链接 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the cei ...

  5. HDU2952:Counting Sheep(DFS)

    Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  6. Hdu2952 Counting Sheep 2017-01-18 14:56 44人阅读 评论(0) 收藏

    Counting Sheep Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  7. ACM HDU-2952 Counting Sheep

    Counting Sheep Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  8. 【Kata Daily 190927】Counting sheep...(数绵羊)

    题目: Consider an array of sheep where some sheep may be missing from their place. We need a function ...

  9. hdu 2952 Counting Sheep

    本题来自:http://acm.hdu.edu.cn/showproblem.php?pid=2952 题意:上下左右4个方向为一群.搜索有几群羊 #include <stdio.h> # ...

随机推荐

  1. 攻城狮在路上(叁)Linux(二十八)--- 打包命令:tar

    首先介绍一下tar打包命令的基本格式,下面的三种之间不能混淆. tar [-j|-z] [cv] [-f 新文件名] file1 file2 ...; tar [-j|-z] [tv] [-f 新文件 ...

  2. CI框架获取post和get参数 CodeIgniter

    请参考:CI文档的输入类部分: $this->input->post() $this->input->get() ------------------------------- ...

  3. [Linux] 解决终端显示乱码问题

    [背景] 公司弄了两台新的虚拟机,用来将原先都部署在一台机器上的JIRA, Fisheye, Confluence迁移到这两台机器上,使用SecureCRT进行登录,使用相关命令时,一台出现乱码,另外 ...

  4. 怎样打开64位 Ubuntu 的32位支持功能?

    转自:http://jingyan.baidu.com/article/7082dc1c539c15e40a89bd3e.html 大多数使用基于 Ubuntu/Debian 的发行版的人都更倾向于选 ...

  5. Java Web 项目获取运行时路径 classpath

    假设资源文件放在maven工程的 src/main/resources 资源文件夹下,源码文件放在 src/main/java/下, 那么java文件夹和resources文件夹在运行时就是class ...

  6. 为什么接口类型可以直接new?

    Runnable rn = new Runnable() { public void run() { } }; 实际相当于,jdk会自动生成一个匿名内部类,完成职责: class Anomymous ...

  7. eclipse中快捷键

    转为大写  ctrl+shift+x 转为小写  ctrl+shift+y 根据类名快速找到类文件 ctrl+shift+r 返回上一级 ALT  +  <- 速定位到某一行 ctrl+L

  8. 《数据结构与算法分析》学习笔记(五)——二叉树

    (一)查找二叉树ADT 1.二叉查找树ADT性质:     对于树中的每个节点X,它的左子树中所有关键字值都小于X的关键字值,而它的右子树值的关键字值都大于X的关键字值. 2.一些ADT的基本操作 结 ...

  9. 《数据结构与算法分析》学习笔记(三)——链表ADT

    今天简单学习了下链表,待后续,会附上一些简单经典的题目的解析作为学习的巩固 首先要了解链表,链表其实就是由一个个结点构成的,然后每一个结点含有一个数据域和一个指针域,数据域用来存放数据,而指针域则用来 ...

  10. LoadRunner编程之跳出迭代

    LoadRunner编程之跳出迭代 51Testing软件测试网3p6pK.Yo LoadRunner中 提供了函数exit(-1)来结束迭代. 使用return 0 来结束本次迭代,进入下一次迭代. ...