python输入一个字符串、计算其中小写字符的个数_输入一串字符,统计其中数字的个数,大写字母的个数和小写字母的个数,其他的不计...

满意答案

00e27ab806e4881f8254fe7ae8741834.png

wayg8q7nyw3

2013.04.06

00e27ab806e4881f8254fe7ae8741834.png

采纳率:54%    等级:13

已帮助:13500人

#include

void count(char*);

int main()

{

char ch[100]={0};

scanf("%s", ch);

count(ch);

return 0;

}

void count(char* ch)

{

//分别记录大写,小写,数字的个数。

int big=0, small=0, character=0;

while (*ch)

{

if ((*ch>='A')&&(*ch<='Z'))

{

++big;

}

if ((*ch>='a')&&(*ch<='z'))

{

++small;

}

if ((*ch>='0')&&(*ch<='9'))

{

++character;

}

++ch;

}

printf("大写字母的个数是:%d\n", big);

printf("小写字母的个数是:%d\n", small);

printf("数字的个数是:%d\n", character);

}

这次应该能看懂了吧!

01分享举报