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;
    }
    
  • 相关阅读:
    通用标签
    网页基础
    WCF---服务发布的步骤
    锁·——lock关键字详解
    C# 实现磁性窗体
    C#中的线程(三) 使用多线程
    C#中的线程(二) 线程同步基础
    C#中的线程(一)入门
    class A<T> where T:class 这个泛型类中的Where T:class什么意思
    OO真经——关于面向对象的哲学体系及科学体系的探讨(下)
  • 原文地址:https://www.cnblogs.com/lwp-nicol/p/14279293.html
Copyright © 2011-2022 走看看