2001. Counting 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的更多相关文章
- 【DFS深搜初步】HDOJ-2952 Counting Sheep、NYOJ-27 水池数目
[题目链接:HDOJ-2952] Counting Sheep Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 ...
- Counting sheep...
Counting sheep... Description: Consider an array of sheep where some sheep may be missing from their ...
- HDU-2952 Counting Sheep (DFS)
Counting Sheep Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- HDU 2952 Counting Sheep(DFS)
题目链接 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the cei ...
- HDU2952:Counting Sheep(DFS)
Counting Sheep Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- 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 ...
- ACM HDU-2952 Counting Sheep
Counting Sheep Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 【Kata Daily 190927】Counting sheep...(数绵羊)
题目: Consider an array of sheep where some sheep may be missing from their place. We need a function ...
- hdu 2952 Counting Sheep
本题来自:http://acm.hdu.edu.cn/showproblem.php?pid=2952 题意:上下左右4个方向为一群.搜索有几群羊 #include <stdio.h> # ...
随机推荐
- Elasticsearch在Windows下的安装
下载Elasticsearch,地址:elasticsearch.org/download 下载jdk,百度搜索jdk下载即可 配置JAVA_HOME变量,配置方法在此文:http://jingyan ...
- css2
CSS 实现div宽度根据内容自适应 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...
- hdu 5288 数学 ****
给一个序列 定义函数f(l ,r) 为区间[l ,r] 中 的数ai不是在这个区间其他任意数aj的倍数 求所有f(l,r)之和 通过预处理,记录 a[i] 的左右边界(所谓的左右边界时 在从 a[i] ...
- [Tools] Eclipse使用小技巧-持续更新
[背景] 使用之中发现一些eclipse使用的小技巧,记录下来供以后查阅 Eclipse保存preferences,并导入到其他workspaces The Export wizard can b ...
- TI Zigbee Light Link 参考设计
TI Zigbee Light Link 参考设计 原文出处: http://processors.wiki.ti.com/index.php/Category:ZigBee_Light_Link ...
- leetcode4568
date: 2015-09-13 16:32:49 Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of ...
- 用C#基于WCF创建TCP的Service供Client端调用
本文将详细讲解用C#基于WCF创建TCP的Service供Client端调用的详细过程 1):首先创建一个Windows Service的工程 2):生成的代码工程结构如下所示 3):我们将Servi ...
- Excel动态合并行、合并列
背景: 在北京工作的时候,又一次同事问了我这样一个问题,说我要把从数据库获取到的数据直接通过NPOI进行导出,但是我对导出的格式要特殊的要求,如图: 冥思苦想,最终顺利帮同事解决问题,虽然有点瑕疵,但 ...
- 【项目经验】 Html Select 遇上 Easyui
一.背景: 当我在做课表选择触发事件的时候,我发现了一个问题,就是我们直接用的easyui-combobox里面的的绑定事件(onchange)貌似触发不了,这是为什么呢? 二.结论及方法 .原始方法 ...
- android常用对话框封装
在android开发中,经常会用到对话框跟用户进行交互,方便用户可操作性:接下来就对常用对话框进行简单封装,避免在项目中出现冗余代码,加重后期项目的维护量:代码如有问题欢迎大家拍砖指正一起进步. 先贴 ...