백준 1316 그룹단어체크

hyun20·2021년 7월 20일
0

문자열 문제

#include <iostream>
#include <string>
using namespace std;
int answer = 0;
void isCount(string word) {
	int alpha[26] = { 0 };
	char tmp='0'; //이전 문자 저장
	for (int i = 0; i < word.length(); i++) {
		if (word[i] != tmp)
			alpha[word[i] - 'a']++;
		tmp = word[i];
	}
	for (int i = 0; i < 26; i++) {
		if (alpha[i] > 1) return;
	}
	answer++;
}
int main() {
	int testN; string word;
	cin >> testN;
	for (int i = 0; i < testN; i++) {
		cin >> word;
		isCount(word);
	}
	cout << answer;
}

0개의 댓글