问题描述
- 菜鸟级C语言问题,求帮助~
- 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 vowelsinserts a character ""."" before each consonantreplaces 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.
InputThe 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.
OutputPrint the resulting string. It is guaranteed that this string is not empty.
Sample test(s)
inputtour
output
.t.r
input
Codeforces
output
.c.d.f.r.c.s
input
aBAcAba
output
.b.c.b
我的答案:
#include
#includeint main()
{
char a[100];
int lengthi;
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就退出循环,后面还要检查呢。
解决方案三:
你的结果报什么错??
解决方案四:
这哪是菜鸟级别和我们抢菜鸟行吗?再抢我们菜鸟都不如了。。。