Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 16:01:15
Original
1895 people have browsed it

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);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!