C语言程序题写一个函数,由实参传
对楼上的略作修改:
#include
#include
void stat(char *str)
{
int n1,n2,n3,n4;
n1 = n2 = n3 = n4 = 0;
while (*str!='\0')
{
if ((*str >= 'a' && *str = 'A' && *str = '0' && *str <= '9')
n2++;
else if (*str == ' ')
n3++;
else n4++;
str++;
}
printf("the string has %d letters, %d numbers, %d spaces and %d other c...全部
对楼上的略作修改:
#include
#include
void stat(char *str)
{
int n1,n2,n3,n4;
n1 = n2 = n3 = n4 = 0;
while (*str!='\0')
{
if ((*str >= 'a' && *str = 'A' && *str = '0' && *str <= '9')
n2++;
else if (*str == ' ')
n3++;
else n4++;
str++;
}
printf("the string has %d letters, %d numbers, %d spaces and %d other characters。
\n", n1, n2, n3, n4);
}
void main()
{
char str[51];
clrscr();
printf("please enter the string (no more than 50 characters): \n");
gets(str);
stat(str);
getch();
}
。
收起