输入一行字符,编程统计并输出其中大写英文字母和数字的个数
答案:2 悬赏:30
解决时间 2021-12-21 21:28
- 提问者网友:爱你等于作孽
- 2021-12-21 17:18
输入一行字符,编程统计并输出其中大写英文字母和数字的个数
最佳答案
- 二级知识专家网友:末路丶一枝花
- 2021-12-21 17:48
#include
void main() { char str[256],*p; int a,b;
gets(str); a=b=0; p=str;
while ( *p ) {
if ( *p>='A' && *p<='Z' ) a++;
else if ( *p>='0' && *p<='9' ) b++;
p++;
}
printf("大写字母%d,数字%d\n",a,b);
}
void main() { char str[256],*p; int a,b;
gets(str); a=b=0; p=str;
while ( *p ) {
if ( *p>='A' && *p<='Z' ) a++;
else if ( *p>='0' && *p<='9' ) b++;
p++;
}
printf("大写字母%d,数字%d\n",a,b);
}
全部回答
- 1楼网友:晚安听书人
- 2021-12-21 18:53
#include
int main()
{int i,dx=0,sz=0; char s[200];
gets(s);
for(i=0;s[i];i++)
if(s[i]>='a'&&s[i]<='z')dx++;
else if(s[i]>='0'&&s[i]<='9')sz++;
printf("a~z:%d\n0~9:%d\n",dx,sz);
return 0;
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯