2.c 510 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. int main() {
  3. int count = 0;
  4. int min, max;
  5. char target;
  6. char str[100];
  7. while (scanf("%d-%d %c: %s", &min, &max, &target, str) == 4) {
  8. int char_count = 0;
  9. char *str_ptr = str;
  10. char test_c;
  11. while ((test_c = *(str_ptr++)) != '\0') {
  12. if (test_c == target)
  13. char_count++;
  14. }
  15. if (min <= char_count && char_count <= max){
  16. count++;
  17. }
  18. }
  19. printf("%d\n", count);
  20. return 0;
  21. }