用C语言编写在一个字符串中找出元音字母a,e,i,o,u出现的次数。 需要区分 大小写!! 只统计小写元音字

#include<stdio.h>voidHowVowel(int*pr,char*ps){charv[7]="aeiou",i;for(;*ps;ps++)for(i=... #include <stdio.h>
void HowVowel(int *pr,char *ps)
{
char v[7]="aeiou",i;
for(;*ps;ps++)
for(i=0;*(v+i);i++)
if((*ps|0x20)==*(v+i))
pr[i]++;
}

void main(void)
{
char Str[200]="";
int Result[5]={0,},i;
gets(Str);
HowVowel(Result,Str);
for(i=0;i<5;printf("%d ",Result[i++]));
printf("\n");
return 0;
}
上边是目前的代码 格式就是
样例输入If so, you already have a Google Account. You can sign in on the right.
样例输出5 4 3 7 3
但是 目前存在问题就是输入大写也算 求帮忙添加代码来把大写否定了
展开
 我来答
xuning2516
2013-02-26 · TA获得超过643个赞
知道小有建树答主
回答量:607
采纳率:0%
帮助的人:273万
展开全部

  #include <stdio.h>

  void HowVowel(int *pr,char *ps)

  {

  char v[7]="aeiou";

  for(;*ps;ps++)

  {

  switch(*ps)

  {

  case 'a':

  ++pr[0];

  break;

  case 'e':

  ++pr[1];

  break;

  case 'i':

  ++pr[2];

  break;

  case 'o':

  ++pr[3];

  break;

  case 'u':

  ++pr[4];

  break;

  default:

  break;

  }

  }

  }

  int main(void)

  {

  char Str[200]="";

  int Result[5]={0,},i;

  gets(Str);

  HowVowel(Result,Str);

  for(i=0;i<5;printf("%d ",Result[i++]));

  printf("\n");

  return 0;

  }


追问
不对啊 这是C语言 中的么   我怎么不可以  
各种提示

错误 1 error C3872: “0x3000”: 此字符不允许在标识符中使用

错误 2 error C2014: 预处理器命令必须作为第一个非空白空间启动
错误 5 error C2061: 语法错误 : 标识符“  void”
追答
你是什么编译器呢 我的是vc6,。0
_whales
2013-02-26 · TA获得超过2279个赞
知道大有可为答主
回答量:1814
采纳率:85%
帮助的人:462万
展开全部
在你的代码上的修改,去掉|0x20,这个是包含大小写的;
void HowVowel(int *pr,char *ps)
{
char v[7]="aeiou",i;
for(;*ps;ps++)
for(i=0;*(v+i);i++)
if((*ps)==*(v+i))
pr[i]++;
}
修改一下:
void HowVowel(int *pr,char *ps)
{
char v[]="aeiou",i;
int count[26]={0}
for(;*ps;ps++)
if(*ps<='z' && *ps>='a')count[*ps-'a']++;各个字母

for(i=0;v[i];i++)pr[i]=count[v[i]-'a'];
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
伊·梵beec
2013-02-26 · TA获得超过2158个赞
知道大有可为答主
回答量:1897
采纳率:0%
帮助的人:1337万
展开全部
只要小写的话
if(*ps==*(v+i))

if((*ps|0x20)==*(v+i))
是一个取巧的办法,可以将‘A'-’Z'转换为'a'-'z'
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式