Advertisement
Neg0day

Untitled

May 29th, 2021
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. int includes(char* word) {
  5. int n, i;
  6. if (word == NULL) return 0;
  7. if (strlen(word) == 1) return 0; // если одна буква
  8. n = strlen(word);
  9. for (i = 0; i < n; ++i) if (word[0] == word[strlen(word) - 1]) return 1;
  10. return 0;
  11. }
  12. int main(void) {
  13. char* token = NULL;
  14. char* next_token = NULL;
  15. int count = 0;
  16. system("chcp 1251 > nul");
  17. char line[] = "Слова которые начинаются на одну и ту же букву будут: тут боб тест";
  18. puts(line);
  19. token = strtok_s(line, " ", &next_token);
  20. count += includes(token);
  21. while (token != NULL) {
  22. token = strtok_s(NULL, " ", &next_token);
  23. count += includes(token);
  24. }
  25. printf("Количество: %i\n", count);
  26. system("pause > nul");
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement