描述:
输入一串字符,以“?”结束。统计其中字母个数,数字个数,其它符号个数。
输入格式:
输入一行,包含若干个字符,以”?”结尾。
输出格式:
输出三行,每行包含一个整数,依次为字母个数,数字个数,其他符号个数。
样例输入:
ab123!?
样例输出:
Letters=2
Digits=3
Others=1
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
char ch;
int main(){
do{
ch=getchar();
if(ch=='?')break;
if(ch>='0'&&ch<='9')a++;
else if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))b++;
else c++;
}while(ch!='?');
printf("Letters=%d Digits=%d Others=%d ",b,a,c);
return 0;}
感谢大家欣赏这篇文章,求点赞👍🏻,谢谢。