Tsukinai的第七十四个程序
写一个函数,将一个字符串中的元音字母复制到另一个字符串,然后输出。
程序的运行示例如下:
提示信息:"\n输入字符串:"
字符串中的元音字母是eoo
输入数据格式:使用gets()
输出数据格式:"\n字符串中的元音字母是%s"
程序运行示例:
输入字符串:Hello,world!↙
Hello,world!
字符串中的元音字母是eoo
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
char a[50], b[50];
printf("\n输入字符串:");
gets(a);
int i, j = 0, len;
len = strlen(a);
for (i = 0; i < len; i++)
{
if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u')
{
b[j] = a[i];
j++;
}
}
b[j] = '\0'; //给b加上结束标志
printf("%s", a);
printf("\n字符串中的元音字母是%s", b);
system("pause");
return 0;
}