fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. const int WORD_SIZE = 10;
  6. const int TEXT_SIZE = 1000;
  7. const int CASE_DIF = 'a' - 'A';
  8.  
  9. bool isSmalLetter(char c) {
  10. return c >= 'a' && c <= 'z';
  11. }
  12.  
  13. void capsLock(char word[], const int SIZE) {
  14. for (int i = 0; i < SIZE; ++i) {
  15. if (isSmalLetter(word[i])) {
  16. word[i] = char(word[i] - CASE_DIF);
  17. }
  18. }
  19. }
  20.  
  21. int main() {
  22. char word[WORD_SIZE + 1];
  23. cin.getline(word, WORD_SIZE + 1);
  24. const int WORD_LENGTH = int(strlen(word));
  25. capsLock(word, WORD_LENGTH);
  26. char line[TEXT_SIZE + 1];
  27. int count = 0;
  28. while (cin.getline(line, TEXT_SIZE + 1)) {
  29. char *p = strchr(line, word[0]);
  30. while (p != 0) {
  31. int start = 0;
  32. while (word[start] == line[int(p - line) + start] && start < WORD_LENGTH) {
  33. ++start;
  34. }
  35. if (start == WORD_LENGTH) {
  36. ++count;
  37. }
  38. p = strchr(p + 1, word[0]);
  39. }
  40. }
  41. cout << count;
  42. return 0;
  43. }
Success #stdin #stdout 0s 5284KB
stdin
flaviudan
FLAVIUDAN FLAVIU DAN DAN FLAVIU FLAVIUDAN flaviuDan

FLAVIUDAN DANFLAVIU FLAVIU DAN DAN FLAVIU
stdout
3