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. OCJP(1Z0-851) 模拟题分析(九)over

    Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...

  2. 查看Linux分区格式

    第一种方法: 使用mount   [root@ol6-121-rac1 ~]# mount /dev/mapper/vg_ol6121rac1-lv_root on / type ext4 (rw) ...

  3. hdu 1517 博弈 **

    博弈题: 题意:2 个人玩游戏,从 1 开始,轮流对数进行累乘,直到超过一个指定的值. 解题思路:如果输入是 2 ~ 9 ,因为Stan 是先手,所以Stan 必胜如果输入是 10~18 ,因为Oll ...

  4. IIS配置php运行环境默认加载的php.ini路径

    第一步: 把PHP的安装路径添加到环境变量Path中,右键 “我的电脑” -> 高级 -> 环境变量 -> 系统变量,追加 D:PHP-5.2.8\; 第二步: 新建“系统变量” P ...

  5. redis如何安装

    http://www.redis.net.cn/download/ (1)下载,解压,编译: $ wget http://download.redis.io/releases/redis-3.0.6. ...

  6. 智能车学习(十四)——K60单片机GPIO学习

    一.头文件: #ifndef __MK60_GPIO_H__ #define __MK60_GPIO_H__ #include "MK60_gpio_cfg.h" /* * 定义管 ...

  7. 汇编学习(三)——汇编语言程序入门

    一.寻址方式 1.概念: 一条指令由操作码和操作数构成,操作码是系统定义好的符号,执行指定的操作,操作数即是指令的对象,而寻址方式就是操作数的指定方式 操作码 目的操作数,源操作数 2.寻址方式的三种 ...

  8. 我的 Unity2D 屏幕适配

    以下方法纯属我YY,切勿当真!!! 确定一个设计尺寸,比如 devWidth = 960,devHeight = 640, 按照这个尺寸进行设计游戏. 方式一: 不管什么屏幕尺寸,都和设计的尺寸对应. ...

  9. javascript概述

    在我们进行javascript视频的时候,第一集,看到的学习要点: 1.什么是javascript?         a.一种具有面向对象能力的.解释型的程序设计语言(直接读取运行,而非编译型)   ...

  10. SQLServer批量创建有规则的数据

    根据需求要生成从kkk001,kkk002开始的100个递增账号 手插要死人的,用SQL脚本轻松完成: declare @a int ) ) begin ) ) end declare:申明变量, @ ...