|
> 例えば、文字列中に"a a","i i","u u"の文字列があったら、
> "aa","ii","uu"に書き換えするプログラムを作りたいです。
#include <stdio.h>
#include <string.h>
void replace(const char *s, char *t)
{
while (*t++ = *s++)
if (strchr("aiueo", s[-1]) && s[0]==' ' && s[1]==s[-1])
s++, *t++ = *s++;
}
int main(void)
{
char buf[1024], buf2[1024];
while (fgets(buf, sizeof buf, stdin)) {
replace(buf, buf2);
fputs(buf2, stdout);
}
return 0;
}
|