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;
    }
    
  • 相关阅读:
    jQuery+ThinkPHP+Ajax实现即时消息提醒功能
    依赖注入(DI)
    控制反转(IoC)
    ajax以base64上传图片到django
    python 多进程、多线程、协程
    python3 实现tcp/udp局域网通信
    同源策略与跨域访问
    nginx+uwsgi阿里云ubuntu服务器上简单部署flask RESTful风格项目
    python3 实现 websocket server 解决中文乱码
    python IO 多路复用 epoll简单模型
  • 原文地址:https://www.cnblogs.com/lwp-nicol/p/14279293.html
Copyright © 2011-2022 走看看