Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
deletes all the vowels,
inserts a character "." before each consonant,
replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.
Help Petya cope with this easy task.
Input
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.
Output
Print the resulting string. It is guaranteed that this string is not empty.
Sample test(s)
input
tour
output
.t.r
input
Codeforces
output
.c.d.f.r.c.s
input
aBAcAba
output
.b.c.b
我的答案:
#include
#include
int main()
{
char a[100];
int length,i;
scanf("%s",&a);
length=strlen(a);
for(i=1;i<=length;i++)
{
if(a[i]=='a'||a[i]=='A'||a[i]=='o'||a[i]=='O'||a[i]=='y'||a[i]=='Y'||a[i]=='e'||a[i]=='E'||a[i]=='u'||a[i]=='U'||a[i]=='i'||a[i]=='I')
{
break;
}
else
{
if(a[i]>=65&&a[i]<=90)
{
printf(".%c",a[i]+32);
}
else if(a[i]>=97&&a[i]<=122)
{
printf(".%c",a[i]);
}
}
}
printf("\n");
return 0;
}
求指点,哪里错了,跪谢!
http://blog.csdn.net/zhaoxinfan/article/details/8612126
你的结果报什么错??
这哪是菜鸟级别和我们抢菜鸟行吗?再抢我们菜鸟都不如了。。。
2个错误:
for(i=0;i<length;i++) //数组下标使用错误,应该从0,到length-1
把break改为continue;不能有一个t就退出循环,后面还要检查呢。