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 ;
}