#include
#include
#include
using namespace std;
void main()
{
string str;
cout<<"请输入要判断的字符串:\n";
char buf[] = {'A', 'E', 'I', 'O', 'U'};
getline(cin, str, '\n'); //得到输入
transform(str.begin(), str.end(), str.begin(), toupper); //将所有字符转换成大写
const int size = sizeof(buf); //计算元音字母个数
unsigned long Count[size]; //用于存储对应元音字母的个数
int i,j;
for(i=0; i
for(i=0; i
for(j=0; j
if (str[j] == buf[i])
{
Count[i]++;
}
}
}
for(i=0; i
cout<<"元音字母 "<<(char)buf[i]<<" 的个数为:"<
}
#include
#include
using namespace std;
void func(string s,int a[]);
int main()
{
string str = "AVERWT245537-+-QWabceeiouafdagfalldhgahg";
int a[5] = {0};
func(str,a);
cout<<"a/A times: "< cout<<"e/E times: "< cout<<"i/I times: "< cout<<"o/O times: "< cout<<"u/U times: "<
return 0;
}
void func(string s,int a[])
{
int i = 0;
while (i < s.length())
{
if (isalpha(s[i]))
{
switch (s[i])
{
case 'a':
case 'A':
++a[0];
break;
case 'e':
case 'E':
++a[1];
break;
case 'i':
case 'I':
++a[2];
break;
case 'o':
case 'O':
++a[3];
break;
case 'u':
case 'U':
++a[4];
break;
}
}
++i;
}
}