幾個母音(用到指標!!)

 avatar
user_3763047219
c_cpp
2 years ago
383 B
2
Indexable
Never
int main()
{
	char alphabet[1000] = {};
	char* ptr = alphabet;
	int count = 0;
	scanf("%s", ptr);
	for (int i = 0; i < strlen(ptr); i++) {
		if (ptr[i] == 'a' || ptr[i] == 'e' || ptr[i] == 'i' || ptr[i] == 'o' || ptr[i] == 'u'
			|| ptr[i] == 'A' || ptr[i] == 'E' || ptr[i] == 'I' || ptr[i] == 'O' || ptr[i] == 'U') {
			count = count + 1;
		}
	}
	printf("%d", count);
}