c语言实现统计字符串中元音字母的个数
时间: 2024-06-13 21:09:41 浏览: 175
统计字符串中元音字母的个数
```c
#include <stdio.h>
#include <string.h>
int main()
{
char str[100];
int vowels = 0, i;
printf("请输入一个字符串:");
gets(str);
for (i = 0; str[i] != '\0'; ++i) {
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' ||
str[i] == 'o' || str[i] == 'u' || str[i] == 'A' ||
str[i] == 'E' || str[i] == 'I' || str[i] == 'O' ||
str[i] == 'U') {
++vowels;
}
}
printf("字符串中元音字母的个数为:%d", vowels);
return 0;
}
```
--相关问题--:
1. 如何统计字符串中某个字符的个数?
2. 如何判断一个
阅读全文