zoukankan      html  css  js  c++  java
  • 文章中字符数统计

    1150 文章中字符数统计

    题目描述

    有一篇文章,共有3段文字,每段不超过1000个字符。要求统计其中英文大写字母、英文小写字母、数字的个数。

    输入描述

    /*
    输入3段文字。
    */
    Technology firm Apple has become the most valuable company in the US, with its market capitalisation overtaking that of Exxon Mobil.
    Apple had briefly become the largest US firm on Tuesday, before dropping back below the oil giant.
    But Apple has now managed to stay in the top spot at the close of Wall Street for the first time.
    

    输出描述

    /*
    输出统计结果,依次显示大写英文字母个数,小写英文字母个数,数字字符个数。
    */
    14 252 0
    
    #include<stdio.h>
    #include<string.h>
    
    int lownumber(char s[]){
        int counts =0;
        int len = strlen(s);
        int i =0;
        for(i = 0;i<len;i++){
            if(s[i]>='A'&&s[i]<='Z')
                counts++;
        }
        return counts;
    }
    
    int highnumber(char s[]){
        int counts =0;
        int len = strlen(s);
        int i =0;
        for(i = 0;i<len;i++){
            if(s[i]>='a'&&s[i]<='z')
                counts++;
        }
        return counts;
    }
    
    int numnumber(char s[]){
        int counts =0;
        int len = strlen(s);
        int i =0;
        for(i = 0;i<len;i++){
            if(s[i]>='0'&&s[i]<='9')
                counts++;
        }
        return counts;
    }
    
    int lowercasecount(char s[][1000]){
        int counts =0;
        int i =0;
        for(i = 0;i<3;i++){
            counts+= lownumber(s[i]);
        }
        return counts;
    }
    
    int highcasecount(char s[][1000]){
        int counts =0;
        int i =0;
        for(i = 0;i<3;i++){
            counts+=highnumber(s[i]);
        }
        return counts;
    }
    
    int numcount(char s[][1000]){
        int counts =0;
        int i =0;
        for(i = 0;i<3;i++){
            counts+=numnumber(s[i]);
        }
        return counts;
    }
    
    void countstr(char s[][1000]){
        int lowcase = lowercasecount(s);
        int highcase = highcasecount(s);
        int num = numcount(s);
        printf("%d %d %d
    ",lowcase,highcase,num);
    }
    
    int main()
    {
       char str[3][1000]={0};
       int i=0;
       for(i = 0;i<3;i++){
            gets(str[i]);
       }
       countstr(str);
       return 0;
    }
    
  • 相关阅读:
    [Leetcode] Maximum Gap
    [Leetcode] Reverse Integer
    [Leetcode] Pow(x, n)
    Theano2.1.21-基础知识之theano中多核的支持
    Theano2.1.3-基础知识之更多的例子
    Theano2.1.17-基础知识之剖析theano的函数
    Theano2.1.16-基础知识之调试:常见的问题解答
    Theano2.1.15-基础知识之theano如何处理shapre信息
    Theano2.1.14-基础知识之理解为了速度和正确性的内存别名
    Theano2.1.13-基础知识之PyCUDA、CUDAMat、Gnumpy的兼容
  • 原文地址:https://www.cnblogs.com/lwp-nicol/p/14279293.html
Copyright © 2011-2022 走看看