50鱼币有偿求助!各位帮忙看看
#include <stdio.h>#include <stdlib.h>
int main()
{
int letter,digit,blank,other;
char c;
letter=digit=blank=other=0;
printf("Please enter a sentence:");
while((c=getchar())!='/n')
{
if((c>='A'&&c<='Z')||(c>='a'&&c<='z'))
letter++;
else if(c>='0'&&c<='9')
digit++;
else if(c==' ')
blank++;
else other++;
}
printf("letter = %d, blank = %d, digit = %d, other = %d",letter,blank,digit,other);
return 0;
}
各位能帮我看看吗?不知道为什么这段代码始终运行不了 不懂C 回车符打错了,是\n {:10_269:} #include <stdio.h>
#include <stdlib.h>
int main(void)
{
int letter, digit, blank, other;
char c;
letter = digit = blank = other = 0;
printf("Please enter a sentence:");
while ((c = getchar()) != '\n') // 应该是\n,/n是错的
{
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
letter++;
else if (c >= '0' && c <= '9')
digit++;
else if (c == ' ')
blank++;
else
other++;
}
printf("letter = %d, blank = %d, digit = %d, other = %d", letter, blank, digit, other);
return 0;
} 楼上已经有答案。 赞 看答案
学习{:10_258:}
页:
[1]