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. ExcelReport第二篇:ExcelReport源码解析

    导航 目   录:基于NPOI的报表引擎——ExcelReport 上一篇:使用ExcelReport导出Excel 下一篇:扩展元素格式化器 概述 针对上一篇随笔收到的反馈,在展开对ExcelRep ...

  2. uploadify文件批量上传

    uploadify能够时间文件的批量上传,JS文件包下载地址,使用说明可以参考官网文档(http://www.uploadify.com/documentation/) 使用方法如下代码: $(&qu ...

  3. CentOS FTP基于虚拟用户的配置

    详细可以看:http://www.linuxidc.com/Linux/2013-12/94242.htm 所谓虚拟用户就是没有使用真实的帐户,只是通过映射到真实帐户和设置权限的目的.虚拟用户不能登录 ...

  4. 2-01SQL的概述

    SQL: Structured Query Languaage:结构化查询语言. 美国国家标准局ANSI. 国际标准化组织. T-SQL: Transact-SQL. T-SQL是SQL的扩展集. 对 ...

  5. WPF 实现带标题的TextBox

    这篇博客将分享在WPF中如何创建一个带Title的TextBox.首先请看一下最终的效果, 实现思路:使用TextBlock+TextBox来实现,TextBlock用来显示Title. 实现代码, ...

  6. 二叉搜索树的实现及指针问题的一点思考(C++)

    今天实现二叉搜索树的时候因为指针的问题卡了一上午(实在不应该...),一直segmentation fault,个人感觉还是需要记录一下的. 首先贴一下做的题的意思: 输入一系列整数,建立二叉排序数, ...

  7. C++读取txt文件

    1. 逐行读入 void readTxt(string file) { ifstream infile; infile.open(file.data()); //将文件流对象与文件连接起来 asser ...

  8. 用计算器计算“异或CRC”

    再计算器上输入以下数字,每输入一个数字,按一下“Xor”

  9. 将一个正整数分解为m个2的n次方的和

    -- ============================================= -- Author:      <maco_wang> -- Create date: & ...

  10. Hadoop Mapreduce分区、分组、二次排序过程详解[转]

    原文地址:Hadoop Mapreduce分区.分组.二次排序过程详解[转]作者: 徐海蛟 教学用途 1.MapReduce中数据流动   (1)最简单的过程:  map - reduce   (2) ...