Skip to content

Instantly share code, notes, and snippets.

@chomado
Created May 4, 2014 09:05
Show Gist options
  • Save chomado/d9124f81ddfc5cbbcc67 to your computer and use it in GitHub Desktop.
Save chomado/d9124f81ddfc5cbbcc67 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main(void)
{
char keyword[11];
char word[32];
int counter = 0;
memset(keyword, '\0', sizeof(keyword));
memset(word, '\0', sizeof(word));
scanf("%s", keyword);
getchar();
while (scanf("%s", word), strcmp(word, "END_OF_TEXT"))
if (!(strcasecmp(word, keyword))) counter++;
printf("%d\n", counter);
return 0;
}
@chomado
Copy link
Author

chomado commented May 4, 2014

SAMPLE

Input:
computer // <- keyword
Nurtures computer scientists and highly-skilled computer engineers
who will create and exploit "knowledge" for the new era.
Provides an outstanding computer environment.
END_OF_TEXT

Output:
3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment