欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

输入一行字符,分别统计出其中英文,空格,数字和其他字符的个数

程序员文章站 2022-05-06 15:04:26
...

int c = 0, space = 0, num = 0, other = 0; char s[] = djwiJFIW 123@#$!%; // scanf(%s, s); char *str = s; while (*str != \0) { if ((*str = A *str = Z) || (*str = a *str = z)) { c++; }else if (*str == ){ space++; }else if (*str = 0 *str = 9){

int c = 0, space = 0, num = 0, other = 0;

char s[] = "djwiJFIW 123@#$!%";

// scanf("%s", s);

char *str = s;

while (*str != '\0') {

if ((*str >= 'A' && *str = 'a' && *str

c++;

}else if (*str == ' '){

space++;

}else if (*str >= '0' && *str

num++;

}else{

other++;

}

str++;

printf("%c ", *str);

}

printf("英文,空格,数字和其他字符的个数分别为: %d,%d,%d,%d\n", c, space, num, other);