用C程序编写一个函数,将一个字符串中的元音字母复制到另一个字符串,然后输出 5
1个回答
展开全部
#include <stdio.h>
#include <stdlib.h>
char vowel[]={'A','E','I','O','U','a','e','i','o','u'};
char IsGetVowel(char s)
{
int l;
for (l=0;l<sizeof(vowel);l++)
{
if(s==vowel[l])
{
break;
}
}
if(l<sizeof(vowel))
{
return s;
}
else
{
return '\0';
}
}
unsigned __int32 ScanVowel(char* Source,char* Target)
{
char *p,*s,tmp;
unsigned __int32 R=0;
p=Source;
s=Target;
while(*p!='\0')
{
tmp=IsGetVowel(*p++);
if(tmp!='\0')
{
R++;
*s++=tmp;
}
}
*s='\0';
return R;
}
int main(int argc, char* argv[])
{
char Str1[32],Str2[32];
scanf("%s",Str1);
ScanVowel(Str1,Str2);
printf("%s\n",Str2);
system("Pause");
return 0;
}
RadStudio 2010编译通过
#include <stdlib.h>
char vowel[]={'A','E','I','O','U','a','e','i','o','u'};
char IsGetVowel(char s)
{
int l;
for (l=0;l<sizeof(vowel);l++)
{
if(s==vowel[l])
{
break;
}
}
if(l<sizeof(vowel))
{
return s;
}
else
{
return '\0';
}
}
unsigned __int32 ScanVowel(char* Source,char* Target)
{
char *p,*s,tmp;
unsigned __int32 R=0;
p=Source;
s=Target;
while(*p!='\0')
{
tmp=IsGetVowel(*p++);
if(tmp!='\0')
{
R++;
*s++=tmp;
}
}
*s='\0';
return R;
}
int main(int argc, char* argv[])
{
char Str1[32],Str2[32];
scanf("%s",Str1);
ScanVowel(Str1,Str2);
printf("%s\n",Str2);
system("Pause");
return 0;
}
RadStudio 2010编译通过
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询