[YTU]_1032( 统计出其中英文字母、数字、空格和其他字符的个数)

Description

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

Input

一行字符

Output

统计值

Sample Input

aklsjflj123 sadf918u324 asdf91u32oasdf/.';123

Sample Output

23 16 2 4
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char str[101];
    int i,a=0,b=0,c=0,d=0;
    gets(str);
    for(i=0;str[i]!='';i++)
    {
        if((str[i]>=65&&str[i]<=90)||(str[i]>=97&&str[i]<=122))
            a++;
        else if(str[i]>=48&&str[i]<=57)
            b++;
        else if(str[i]==' ')
            c++;
        else
            d++;
    }
        cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
    return 0;
}


原文地址:https://www.cnblogs.com/sxy201658506207/p/7586399.html