#include <stdio.h>
#include <string.h>
#include <ctype.h>
//Занести в выходную строку все слова исходной строки, которые отличны от последнего слова.
char* task0(char* d, char* s) {
char* t = d;
char* a, *b;
for(b = s + (strlen(s) - 1); (b > s) && (! isalpha(*b)); *b--);
for(a = b; (a > s) && (isalpha(*a)); *a--);
++a;
while(s < a) {
if(isalpha(*s)) {
if(! strncmp(s, a, b - a)) {
if(! isalpha(*(s + (b - a) + 1))) {
s += (b - a) + 1;
continue;
}
}
}
*d++ = *s++;
}
*d = '\0';
return t;
}
//Перед каждым словом, начинающимся с буквы 'a' добавить слово "вот".
char* task3(char* s, char c, const char* r) {
char* t = s;
size_t n = strlen(r);
while(*s) {
if(isalpha(*s)) {
if(*s == c) {
memmove(s + n, s, strlen(s) - n);
strncpy(s, r, n);
s += n + 1;
}
while(*s && (isalpha(*s)))
*s++;
} else
*s++;
}
return t;
}
int main(){
char s[64] = "the bot bla-bot asp, the apple bottle bot.";
char d[64];
task0(d, s);
puts(d);
task3(s, 'a', "vot ");
puts(s);
return 0;
}