2.1.c 470 B

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