- #include "stdio.h"
- #define M 1000 // 宏定义字节最大长度
- int character = 0, num = 0, other = 0;
-
- int f(char *x)
- {
- int i = 0;
-
-
- for ( i = 0; *(x+i) != '\0'; i++)
- {
- if (( *( x + i ) >= 'a' && *( x + i) <= 'z') || (*( x + i ) >= 'A' && *( x + i) <= 'Z'))
- character++;
- else if ( *( x + i ) >= '0' && *( x + i) <= '9')
- num++;
- else
- other++;
- }
-
- printf ("The character is:%d\n", character );
- printf ("The number is:%d\n", num );
- printf ("Other is:%d\n", other );
-
- return ( word, num, other);
- }
- main()
- {
-
- char ch[M];
-
- printf ("请输入你要求的字符串\n");
- gets(ch);
-
- f(ch);
-
- }
|
|