回复 楼主 不在状态
#include <stdio.h>
#include <string.h>
#define N 18
#define S str[i]
#define L (int)strlen(str)
int main(void)
{
int i, letter = 0, number = 0, space = 0, others = 0;
char str[N];
printf("Please input a string:");
gets(str);
puts(str);
if ( L <= N )
{
for (i = 0; i < L ; i++)
{
if (S >= 'A' && S <= 'Z' || S >= 'a' && S <= 'z')
letter++;
else if (S >= '0' && S <= '9')
number++;
else if (S == ' ')
space++;
else
others++;
}
printf("This string has:\r\n%d letter\r\n%d number\r\n%d space\r\n%d others\r\n",
letter, number, space, others);
}
else
printf("Stop monkeying about!\n");
return 0;
}