Time Exceeded
/in/foo.c: In function 'main': /in/foo.c:16:13: warning: suggest parentheses around '&&' within '||' [-Wparentheses] if (c >= 'a'&&c <= 'z' || c >= 'A'&&c <= 'Z') ~~~~~~~~^~~~~~~~~~
代码
#include <stdio.h>
int main()
{
char c;
int letters=0,space=0,digit=0,other=0;
while ((c=getchar())!='\n')
{
if (c >= 'a'&&c <= 'z' || c >= 'A'&&c <= 'Z')
{
letters++;
}
else if ( c >= 'A'&&c <= 'Z')
{
letters++;
}
else if (c == ' ')
{
space++;
}
else if (c >= '0'&&c <= '9')
{
digit++;
}
else
{
other++;
}
}
printf("%d,%d,%d,%d",letters,space,digit,other);
return 0;
}