Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- int includes(char* word) {
- int n, i;
- if (word == NULL) return 0;
- if (strlen(word) == 1) return 0; // если одна буква
- n = strlen(word);
- for (i = 0; i < n; ++i) if (word[0] == word[strlen(word) - 1]) return 1;
- return 0;
- }
- int main(void) {
- char* token = NULL;
- char* next_token = NULL;
- int count = 0;
- system("chcp 1251 > nul");
- char line[] = "Слова которые начинаются на одну и ту же букву будут: тут боб тест";
- puts(line);
- token = strtok_s(line, " ", &next_token);
- count += includes(token);
- while (token != NULL) {
- token = strtok_s(NULL, " ", &next_token);
- count += includes(token);
- }
- printf("Количество: %i\n", count);
- system("pause > nul");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement