Rohyoohyun / C

0 stars 0 forks source link

1316 그룹단어 체커 #29

Open Rohyoohyun opened 3 months ago

Rohyoohyun commented 3 months ago
#include <stdio.h>
#include <string.h>
int main(){
    int n, group, cnt = 0;
    char word[100] = {0};

    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%s", word);
        group = 1;
        for(int j = 0; j < strlen(word); j++) {
            for (int k = 0; k < j - 1; k++)
                if (word[j] == word[k] && word[j] != word[j - 1]) {
                    group = 0;
                    break;
                }
            if (group == 0) break;
        }
        if (group == 1) cnt++;
    }

    printf("%d", cnt);

    return 0;
}