zoukankan      html  css  js  c++  java
  • [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;
    }


  • 相关阅读:
    Python正课132 —— Vue 进阶5
    Python正课131 —— Vue 进阶4
    Python正课130 —— Vue 进阶3
    logging模块
    作业20
    suprocess模块
    configparser模块
    hashlib模块
    shutil模块
    序列化模块
  • 原文地址:https://www.cnblogs.com/sxy201658506207/p/7586399.html
Copyright © 2011-2022 走看看