|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
int main()
{
int a=0,i=0,o=0,u=0,j,sum=0,count=0;
int e=0;
char str[10000];
printf("请输入一串英文:");
scanf("%s",&str);
while(1)
{
if(str[count] == '\n')
break;
count++;
sum++;
}
count=0;
for(j=0;j<sum;j++)
{
if(str[count]=='a' or str[count]=='A')
a=a+1;
if(str[count]=='e' or str[count]=='E')
e=e+1;
if(str[count]=='i' or str[count]=='I')
i=i+1;
else if(str[count]=='o' or str[count]=='O')
o=o+1;
if(str[count]=='u' or str[count]=='U')
u=u+1;
count++;
}
printf("a(%d),e(%d),i(%d),o(%d),u(%d)",a,e,i,o,u);
}
- int main()
- {
- int a=0,i=0,o=0,u=0,j,sum=0,count=0;
- int e=0;
- char str[10000];
- printf("请输入一串英文:");
- scanf("%s",&str);
- char ch=getchar();
- printf("%d\n",ch);//你看看10就是\n
- while(1)
- {
- if(str[count] == '\0')//字符串都是以\0结尾的。
- break;
- count++;
- sum++;
- }
- count=0;
- for(j=0;j<sum;j++)
- {
- if(str[count]=='a' || str[count]=='A')
- a=a+1;
- if(str[count]=='e' || str[count]=='E')
- e=e+1;
- if(str[count]=='i' || str[count]=='I')
- i=i+1;
- else if(str[count]=='o' || str[count]=='O')
- o=o+1;
- if(str[count]=='u' || str[count]=='U')
- u=u+1;
- count++;
- }
- printf("a(%d),e(%d),i(%d),o(%d),u(%d)",a,e,i,o,u);
- return 0;
- }
复制代码
|
|