C/C++の宿題片付けます 137代目

このエントリーをはてなブックマークに追加
954デフォルトの名無しさん
>>943
#include <stdio.h>
#include <string.h>
#define N 100

int main(void)
{
    int cnt = 0;
    char s[] = "atg", s2[] = "tcag", buf[N], *p1, *p2;

    p1 = buf;
    while (scanf("%99s", p1) != EOF)
while (*p1)
    p1++;
    p1 = p2 = buf;
    while (*p1) {
while (strchr(s2, *p1) == 0)
    p1++;
*p2++ = *p1++;
    }
    *p2 = *p1;
    p1 = buf;
    while (strstr(p1, s)) {
cnt++;
p1 = (strstr(p1, s));
p1++;
    }
    printf("#ATG is %d\n", cnt);
    return 0;
}