西南科技大学Power OJ:实验六 E: 课本第七章-7 字符串元音字母复制 写一个子函数,将一个字符串中的元音字母复制到另一字符串,然后输出。

Description

写一个子函数,将一个字符串中的元音字母复制到另一字符串,然后输出。
Input
在主函数中输入一个长度在100以内、字母全为小写的字符串。
Output
输出该字符串中所有元音字母组成的字符串。(在子函数中输出)

**Sample Input**
Raw

kmavjulemdikdoldol

**Sample Output**
Raw

aueioo

示例代码:

#include <stdio.h>
#include <string.h>
char a[101],b[101];
int lenb = 0;
void f(char a)
{
    
    
	if(a == 'a' || a=='e' || a=='i' || a=='o' || a=='u')
		b[lenb++]=a;
}
int main ()
{
    
    
	gets(a);
	int lena = strlen(a);
	int i;
	for(i=0;i<lena;i++)
	{
    
    
		f(a[i]);
	}
	for(i=0;i<lenb;i++)
	{
    
    
		printf("%c",b[i]);
	} 
	return 0;          
 } 

猜你喜欢

转载自blog.csdn.net/qq_45281807/article/details/111478672